-
Notifications
You must be signed in to change notification settings - Fork 123
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
add for loop option in tags block #556
base: main
Are you sure you want to change the base?
add for loop option in tags block #556
Conversation
@ChanochShayner can you review it please? |
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.
Very nice!
Please fix your lint errors.
@@ -799,7 +815,38 @@ func getUncloseBracketsCount(bracketsCounters map[hclsyntax.TokenType]int) int { | |||
return sum | |||
} | |||
|
|||
func (p *TerraformParser) parseTagAttribute(tokens hclwrite.Tokens) map[string]string { | |||
func (p *TerraformParser) parseTagAttribute(tokens hclwrite.Tokens) (map[string]string, error) { |
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.
Why change this func signature to return 2 args?
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.
@ChanochShayner
the unmarshal function can return error so i think that need to add option to return error
but if you think that it unnecessary i can remove it:
do you want to replace this:
err := dethcl.Unmarshal([]byte(hclBytes), hclData)
to this:
dethcl.Unmarshal([]byte(hclBytes), hclData)
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.
@ChanochShayner
fix
@@ -50,19 +50,31 @@ func TestTerraformParser_SkipResourceByComment(t *testing.T) { | |||
assert.Empty(t, p.GetSkipResourcesByComment()) | |||
}) | |||
|
|||
t.Run("One resource with skip comment, only that resource added to skipResourcesByComment slice", func(t *testing.T) { |
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.
Why remove this test?
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.
@ChanochShayner
fix
if tagsAttribute != nil { | ||
tagsTokens := tagsAttribute.Expr().BuildTokens(hclwrite.Tokens{}) | ||
parsedTags, _ := parser.parseTagAttribute(tagsTokens) | ||
if block.GetResourceName() == "bucket_var_tags" { |
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 test more than just this resource?
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.
@ChanochShayner
Yes we can test also another resource
but we need to compare it with another expected result
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.
Sounds good to me
@EstyFridman1 you still have some lint issues. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
User description
This feature introduces support for loops within Terraform configurations
fixes:#496
Generated description
Dear maintainer, below is a concise technical summary of the changes proposed in this PR:
Introduce a new feature in the
TerraformParser
class to support for loops within the tags block of Terraform configurations. This enhancement allows users to dynamically generate tags using a for loop, improving flexibility in tag management. ThemodifyBlockTags
andparseTagAttribute
functions have been updated to handle the new for loop syntax. Additionally, test cases have been added to ensure the correct parsing and handling of tags with for loops.TerraformParser
class to enhance tag management flexibility.Modified files (3)
Latest Contributors(2)
go.mod
to ensure compatibility and leverage new features.Modified files (1)
Latest Contributors(2)