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

🐛 fix for terraform <cannot get hcl block> err #1741

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions providers/terraform/resources/hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,19 @@ func newMqlHclBlock(runtime *plugin.Runtime, block *hcl.Block, file *hcl.File) (

snippet := extractHclCodeSnippet(file, block.TypeRange)

r, err := CreateResource(runtime, "terraform.block", map[string]*llx.RawData{
res, err := CreateResource(runtime, "terraform.block", map[string]*llx.RawData{
"type": llx.StringData(block.Type),
"labels": llx.ArrayData(llx.TArr2Raw(block.Labels), types.String),
"start": llx.ResourceData(start, "terraform.fileposition"),
"end": llx.ResourceData(end, "terraform.fileposition"),
"snippet": llx.StringData(snippet),
})

vjeffrey marked this conversation as resolved.
Show resolved Hide resolved
/*
if err == nil {
r.MqlResource().Cache.Store("_hclblock", &resources.CacheEntry{
Data: block,
})
r.MqlResource().Cache.Store("_hclfile", &resources.CacheEntry{
Data: file,
})
}
*/

if err != nil {
return nil, err
}
r := res.(*mqlTerraformBlock)
r.block = plugin.TValue[*hcl.Block]{State: plugin.StateIsSet, Data: block}
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we pass this in the args as an mql resource, i.e. llx.ResourceData?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for the internal implementation,


type mqlTerraformBlockInternal struct {
	block      plugin.TValue[*hcl.Block]
	cachedFile plugin.TValue[*hcl.File]
}

r.cachedFile = plugin.TValue[*hcl.File]{State: plugin.StateIsSet, Data: file}
return r, err
}

Expand Down