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

Match all valid variables; sort variable; tabs over spaces #3

Merged
merged 4 commits into from May 24, 2018

Conversation

alexrudd
Copy link
Contributor

@alexrudd alexrudd commented May 24, 2018

Hey, thanks for creating this tool!

Firstly I had some trouble when running it against variables with numerical characters so I changed the regex matcher to use the same pattern that Terraform uses.

Secondly I added a sort function so that the variables are written to file in order.

And finally I changed the indentation of the variable blocks to use a single tab instead of three spaces. This matches what terraform fmt would do.

@alexandrst88
Copy link
Owner

alexandrst88 commented May 24, 2018

@alexrudd can you please add description? thanks for pr

@alexrudd
Copy link
Contributor Author

Noticed a couple more bugs:

Should now handle variables with upper-case letters and lines containing more than one variable

@@ -17,10 +17,9 @@ var tfFileExt = "*.tf"
var dstFile = "./variables.tf"
var varTemplate = template.Must(template.New("var_file").Parse(`{{range .}}
variable "{{ . }}" {
description = ""
description = ""
Copy link
Owner

Choose a reason for hiding this comment

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

this is not proper format, when you run terraform fmt

@alexandrst88 alexandrst88 merged commit 680b1c3 into alexandrst88:master May 24, 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