-
Notifications
You must be signed in to change notification settings - Fork 350
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
Support custom formats in terraform_naming_convention rule #860
Conversation
Thanks! May take me a couple days but I will review this this week. |
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.
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!
@@ -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 |
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.
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.
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.
@bendrucker I made the corrections to iterate the maps directly. Hope that's better now.
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. |
Forgot to come back to this, finishing up now |
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. |
Thanks a lot @bendrucker. I hope to make more contribution in the future. |
Closes #857