-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Added validate command #3783
Added validate command #3783
Conversation
@radeksimko Any decision on this one ? |
Hey @sorenmat , Also it would help the reviewer & users if you attached docs describing the purpose of that command - i.e. what are the typical errors/mistakes that will be detected and won't be detected. e.g. circular dependencies, offline validation ( It's not quite solving #3190 yet, is it? (ain't saying it should) |
I think it's pretty close to solving #3190 from how I read it. Atleast that is how we use it. |
@sorenmat this seems like a no-brainer. Got time to update this onto master? If not, I'll gladly do it. @phinze, @mitchellh this could use your 👀. Has tests, needs doc & rebase. |
lol, the only merge conflict was in |
@josephholsten I rebased an added some documentation to website/source/docs/commands |
looks great! @phinze this is fully ready for your 👀, has tests & doc. |
Functionally this looks great. There's a few things I'd like to discuss though:
* invalid [HCL](https://github.com/hashicorp/hcl) syntax (e.g. missing trailing quote or equal sign)
* invalid HCL references (e.g. variable name or attribute which doesn't exist)
* same `provider` declared multiple times
* same `module` declared multiple times
* same `resource` declared multiple times
* same `output` declared multiple times
* invalid `module` name
* interpolation used in places where it's unsupported |
|
||
The `terraform verify` command is used to validate the format and structure of the terraform files. | ||
Terraform performas an analysis of the terraform files, and will display information about missing | ||
variables and errors in the structure of the files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reword this a little bit to not mention format
and structure
? What we're really checking is syntax mostly.
Formatting will be checked by fmt
per #4955 eventually.
I would in fact even explicitly mentioned in a separate paragraph that this command does not check the format of your code. We may expand that paragraph later on when we merge fmt
as linked above.
It's pretty much like go vet
VS gofmt
whereas go vet
is what we do.
Besides the things mentioned, this looks really good, I'm looking forward to see it in |
a0991fc
to
8de6b0b
Compare
@radeksimko glad to be able to help, and thanks for an awesome product ! I've renamed the command to validate and updated the documentation as requested. If it is I will be glad to do another PR with that fix :) |
Good catch! I just opened a new issue for this: #5052 I think this is good to go! 🚢 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Added verify command to validate .tf files.
This can be usefull if you want to verify your terraform files on a CI server or as a webhook for
verifying commits to a repository.
It's a simpler verfication than running a terraform plan.
It will verify: