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

Support custom formats in terraform_naming_convention rule #860

Merged
merged 3 commits into from
Aug 18, 2020
Merged

Support custom formats in terraform_naming_convention rule #860

merged 3 commits into from
Aug 18, 2020

Conversation

angelyan
Copy link
Contributor

@angelyan angelyan commented Aug 1, 2020

Closes #857

@bendrucker
Copy link
Member

Thanks! May take me a couple days but I will review this this week.

Copy link
Member

@bendrucker bendrucker left a comment

Choose a reason for hiding this comment

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

Sorry it took a bit longer than expected to take a look at this. Left some initial comments whenever you get a chance. Overall looks good!

docs/rules/terraform_naming_convention.md Outdated Show resolved Hide resolved
docs/rules/terraform_naming_convention.md Outdated Show resolved Hide resolved
docs/rules/terraform_naming_convention.md Outdated Show resolved Hide resolved
docs/rules/terraform_naming_convention.md Outdated Show resolved Hide resolved
rules/terraformrules/terraform_naming_convention.go Outdated Show resolved Hide resolved
@@ -77,91 +99,68 @@ func (r *TerraformNamingConventionRule) Check(runner *tflint.Runner) error {
return fmt.Errorf("Invalid default configuration: %v", err)
}

if err := r.checkDataBlocks(runner, &config, defaultNameValidator); err != nil {
return err
var dataTargets, localTargets, moduleTargets, outputTargets, resourceTargets, variableTargets []RuleTarget
Copy link
Member

Choose a reason for hiding this comment

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

Avoid collecting data into new slices like this. Iterate directly over the maps that Terraform has already allocated for each block type. 👍 to eliminating r.checkLocalValues and similar heavily duplicated methods, but it should be possible to do so without copying data ahead of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bendrucker I made the corrections to iterate the maps directly. Hope that's better now.

@bendrucker
Copy link
Member

Thanks! Will give this a final look later today and make any small adjustments as needed. Appreciate the improvements here, eventually I'll look to cut this rule down to just the default (snake) or fully described custom formats.

@wata727 wata727 modified the milestone: v0.19.0 Aug 14, 2020
@bendrucker
Copy link
Member

Forgot to come back to this, finishing up now

@bendrucker bendrucker merged commit f1c7853 into terraform-linters:master Aug 18, 2020
@bendrucker
Copy link
Member

The code for this rule could definitely use some love, appreciate you working through to add this feature. I spent 20 mins starting to refactor and rename (4x `get*NameValidator methods 😓) but it was quickly turning into a full rewrite. Since this is working, didn't want to continue to hold it up.

@angelyan
Copy link
Contributor Author

Thanks a lot @bendrucker. I hope to make more contribution in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

feat: support named custom formats in terraform_naming_convention rule
3 participants