mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-05 20:40:16 -08:00
refactor(terraform): simplify AllReferences method signature in Attribute (#8906)
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
This commit is contained in:
@@ -718,22 +718,11 @@ func (a *Attribute) ReferencesBlock(b *Block) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (a *Attribute) AllReferences(blocks ...*Block) []*Reference {
|
||||
func (a *Attribute) AllReferences() []*Reference {
|
||||
if a == nil {
|
||||
return nil
|
||||
}
|
||||
refs := a.referencesFromExpression(a.hclAttribute.Expr)
|
||||
for _, block := range blocks {
|
||||
for _, ref := range refs {
|
||||
if ref.TypeLabel() == "each" {
|
||||
if forEachAttr := block.GetAttribute("for_each"); forEachAttr.IsNotNil() {
|
||||
refs = append(refs, forEachAttr.AllReferences()...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return refs
|
||||
return a.referencesFromExpression(a.hclAttribute.Expr)
|
||||
}
|
||||
|
||||
func (a *Attribute) referencesFromExpression(expr hcl.Expression) []*Reference {
|
||||
|
||||
Reference in New Issue
Block a user