From c5f61bc705cf491273a1f218c562414030e8c1d7 Mon Sep 17 00:00:00 2001 From: vjeffrey Date: Fri, 15 Sep 2023 12:07:54 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20for=20terraform=20=20err=20(#1741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes https://github.com/mondoohq/cnquery/issues/1737 --- providers/terraform/resources/hcl.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/providers/terraform/resources/hcl.go b/providers/terraform/resources/hcl.go index 7557ca69a6..fe6cbad554 100644 --- a/providers/terraform/resources/hcl.go +++ b/providers/terraform/resources/hcl.go @@ -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), }) - - /* - 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} + r.cachedFile = plugin.TValue[*hcl.File]{State: plugin.StateIsSet, Data: file} return r, err }