From a417e1c06add986df2d32139dfd852493b2e4f5d Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 27 Sep 2023 02:32:58 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20terraform=20block=20filter?= =?UTF-8?q?=20to=20work=20with=20non-HCL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Richter --- providers/terraform/resources/hcl.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/providers/terraform/resources/hcl.go b/providers/terraform/resources/hcl.go index 85960fd7df..dc0cc3bd35 100644 --- a/providers/terraform/resources/hcl.go +++ b/providers/terraform/resources/hcl.go @@ -95,7 +95,13 @@ func (t *mqlTerraform) blocks() ([]interface{}, error) { func filterBlockByType(runtime *plugin.Runtime, filterType string) ([]interface{}, error) { conn := runtime.Connection.(*connection.Connection) - files := conn.Parser().Files() + parsed := conn.Parser() + if parsed == nil { + // no results, because this is not a regular parsed HCL + return []interface{}{}, nil + } + + files := parsed.Files() var mqlHclBlocks []interface{} for k := range files { @@ -546,9 +552,11 @@ func initTerraformSettings(runtime *plugin.Runtime, args map[string]*llx.RawData if len(blocks) != 1 { // no terraform settings block found, this is ok for terraform and not an error - args["block"] = nil - args["requiredProviders"] = llx.DictData(map[string]interface{}{}) - return args, nil, nil + // TODO: return modified arguments to load from recording + return nil, &mqlTerraformSettings{ + Block: plugin.TValue[*mqlTerraformBlock]{State: plugin.StateIsSet | plugin.StateIsNull}, + RequiredProviders: plugin.TValue[interface{}]{State: plugin.StateIsSet, Data: []interface{}{}}, + }, nil } settingsBlock := blocks[0].(*mqlTerraformBlock)