github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/steampipeconfig/parse/unresolved_block.go (about) 1 package parse 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/hashicorp/hcl/v2" 8 "github.com/turbot/pipe-fittings/hclhelpers" 9 "github.com/turbot/steampipe/pkg/steampipeconfig/modconfig" 10 ) 11 12 type unresolvedBlock struct { 13 Name string 14 Block *hcl.Block 15 DeclRange hcl.Range 16 Dependencies map[string]*modconfig.ResourceDependency 17 } 18 19 func newUnresolvedBlock(block *hcl.Block, name string, dependencies map[string]*modconfig.ResourceDependency) *unresolvedBlock { 20 return &unresolvedBlock{ 21 Name: name, 22 Block: block, 23 Dependencies: dependencies, 24 DeclRange: hclhelpers.BlockRange(block), 25 } 26 } 27 28 func (b unresolvedBlock) String() string { 29 depStrings := make([]string, len(b.Dependencies)) 30 idx := 0 31 for _, dep := range b.Dependencies { 32 depStrings[idx] = fmt.Sprintf(`%s -> %s`, b.Name, dep.String()) 33 idx++ 34 } 35 return strings.Join(depStrings, "\n") 36 }