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

Allow unquoted item names. Fixes #64 #70

Merged
merged 22 commits into from
Oct 6, 2018
Merged

Allow unquoted item names. Fixes #64 #70

merged 22 commits into from
Oct 6, 2018

Conversation

beatcracker
Copy link
Contributor

@beatcracker beatcracker commented Oct 2, 2018

Prerequisites

Put an x into the box(es) that apply:

  • This pull request fixes a bug.
  • This pull request adds a feature.
  • This pull request introduces breaking change.

For more information, see the Contributing Guide.

Description

Fixes invalid syntax error when output/variable name is not quoted in tf file.

Example

output disk_size {
  value  = "${var.disk_size}"
}

Docs are not entirely clear on this, but unquoted items names are accepted by terraform. See: https://www.terraform.io/docs/configuration/syntax.html

Issues Resolved

Checklist

Put an x into all boxes that apply:

Tests

  • I have added tests to cover my changes.
  • All tests pass when I run make test.

Documentation

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Code Style

  • My code follows the code style of this project.

Docs are not entirely clear on this,
but unquoted items names are accepted by terraform

See: https://www.terraform.io/docs/configuration/syntax.html
@metmajer
Copy link
Member

metmajer commented Oct 3, 2018

Hi @beatcracker. Thank you for your contribution!

Looks like your submission is missing tests. Here's a list of places where tests would be necessary:

  1. Define an input and an output in pkg/doc/testdata's variables.tf and outputs.tf, respectively. As an input, I suggest you add an input-unquoted and an output output-unquoted.

  2. When you run make test, you'll see that the tests named TestInputs* and TestOutputs* in pkg/doc/doc_test.go need to be patched.

  3. Finally, the tests inside pkg/print need to be adapted. With pkg/print/json and pkg/print/markdown, all you need to do is to adapt the *.golden files in the respective testdata directories. With the pkg/print/pretty printer, you'll have to fix the expectation in pkg/print/pretty/pretty_test.go.

Let me know if you have any questions.

@metmajer
Copy link
Member

metmajer commented Oct 6, 2018

@beatcracker oh my... I was experimenting with GitHub's online editing feature on pull request branches and it became a total mess. Will take care to fix it!

@beatcracker
Copy link
Contributor Author

beatcracker commented Oct 6, 2018

@metmajer No problem, thanks for the help. I wasn't sure how to merge latest changes to my branch anyway.

@metmajer
Copy link
Member

metmajer commented Oct 6, 2018

@beatcracker so, here's the thing... GitHub's online editor adds a trailing newline whenever a file is edited. However, this breaks tests with files json.golden and json-WithSorting.golden. Could you please remove the trailing newlines in these files and commit? Then the tests will be green and we are good to merge 👍

@beatcracker
Copy link
Contributor Author

beatcracker commented Oct 6, 2018

GitHub's online editor adds a trailing newline whenever a file is edited.

I guess it makes it POSIX-compatible then 😃 .

@metmajer
Copy link
Member

metmajer commented Oct 6, 2018

I’m OK with the .golden files not being compliant and only contain what they should 😜

@metmajer
Copy link
Member

metmajer commented Oct 6, 2018

Great work, @beatcracker!

@metmajer metmajer merged commit c741028 into terraform-docs:master Oct 6, 2018
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.

None yet

2 participants