Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hclwrite: Generate multi-line objects and maps #372

Merged
merged 1 commit into from
May 6, 2020

Conversation

alisdair
Copy link
Member

@alisdair alisdair commented May 6, 2020

The previous syntax for object and map values was a single line of key-value pairs. For example:

object = { bar = 5, baz = true, foo = "foo" }

This is very compact, but in practice for many HCL values, less readable and less common than a multi-line object format. This commit changes the generated output from hclwrite to one line per attribute.

Examples of the new format:

// Empty object/map is a single line
a = {}

// Single-value object/map has the attribute on a separate line
b = {
  bar = 5
}

// Multi-value object/map has one line per attribute
c = {
  bar = 5
  baz = true
}

The previous syntax for object and map values was a single line of
key-value pairs. For example:

  object = { bar = 5, baz = true, foo = "foo" }

This is very compact, but in practice for many HCL values, less readable
and less common than a multi-line object format. This commit changes the
generated output from hclwrite to one line per attribute.

Examples of the new format:

  // Empty object/map is a single line
  a = {}

  // Single-value object/map has the attribute on a separate line
  b = {
    bar = 5
  }

  // Multi-value object/map has one line per attribute
  c = {
    bar = 5
    baz = true
  }
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! It's a small change, and I think you're good to merge, but it's not a bad idea to wait for @apparentlymart 's review too as I am not the most experienced hclwriter

@alisdair
Copy link
Member Author

alisdair commented May 6, 2020

Thanks, @mildwonkey! Based on your review and a conversation with @apparentlymart yesterday, I feel fairly confident that this is a reasonable thing to do. It's also blocking a Terraform PR, so I'll merge & release, and undo it if it turns out to have been a bad idea.

@alisdair alisdair merged commit 60bf88b into hcl2 May 6, 2020
@alisdair alisdair deleted the format-objects-maps-on-multiple-lines branch May 6, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants