diff --git a/pkg/db/db_common/introspection_tables.go b/pkg/db/db_common/introspection_tables.go index 94d28abd0..5f151bccb 100644 --- a/pkg/db/db_common/introspection_tables.go +++ b/pkg/db/db_common/introspection_tables.go @@ -156,6 +156,21 @@ func getTableCreateSqlForResource(s interface{}, tableName string, commonColumnS columnDefinitions = append(columnDefinitions, getColumnDefinitions(hr.GetHclResourceImpl())...) } + // Query cannot define 'query' as a property. + // So for a steampipe_query table, we will exclude the query column. + // Here we are removing the column named query from the 'columnDefinitions' slice. + if tableName == "steampipe_query" { + // find the index of the element 'query' and store in idx + for i, col := range columnDefinitions { + if col == " query text" { + // remove the idx element from 'columnDefinitions' slice + columnDefinitions = utils.RemoveElementFromSlice(columnDefinitions, i) + break + } + } + + } + tableSql := fmt.Sprintf(`create temp table %s ( %s );`, tableName, strings.Join(columnDefinitions, ",\n")) diff --git a/pkg/steampipeconfig/modconfig/control.go b/pkg/steampipeconfig/modconfig/control.go index beb8414e1..af7f53f9b 100644 --- a/pkg/steampipeconfig/modconfig/control.go +++ b/pkg/steampipeconfig/modconfig/control.go @@ -2,13 +2,13 @@ package modconfig import ( "fmt" - "github.com/zclconf/go-cty/cty" "strings" "github.com/hashicorp/hcl/v2" "github.com/turbot/go-kit/types" typehelpers "github.com/turbot/go-kit/types" "github.com/turbot/steampipe/pkg/utils" + "github.com/zclconf/go-cty/cty" ) // Control is a struct representing the Control resource @@ -163,7 +163,7 @@ func (c *Control) GetParentNames() []string { func (c *Control) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { c.setBaseProperties() - return nil + return c.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } // GetWidth implements DashboardLeafNode diff --git a/pkg/steampipeconfig/modconfig/dashboard_card.go b/pkg/steampipeconfig/modconfig/dashboard_card.go index b0b941168..1909c310b 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_card.go +++ b/pkg/steampipeconfig/modconfig/dashboard_card.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/zclconf/go-cty/cty" "github.com/turbot/steampipe/pkg/utils" @@ -62,7 +63,7 @@ func (c *DashboardCard) Equals(other *DashboardCard) bool { // OnDecoded implements HclResource func (c *DashboardCard) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { c.setBaseProperties() - return nil + return c.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } func (c *DashboardCard) Diff(other *DashboardCard) *DashboardTreeItemDiffs { diff --git a/pkg/steampipeconfig/modconfig/dashboard_chart.go b/pkg/steampipeconfig/modconfig/dashboard_chart.go index 277772441..a29efc234 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_chart.go +++ b/pkg/steampipeconfig/modconfig/dashboard_chart.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/zclconf/go-cty/cty" "github.com/hashicorp/hcl/v2" @@ -69,7 +70,7 @@ func (c *DashboardChart) OnDecoded(block *hcl.Block, resourceMapProvider Resourc c.Series[s.Name] = s } } - return nil + return c.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } func (c *DashboardChart) Diff(other *DashboardChart) *DashboardTreeItemDiffs { diff --git a/pkg/steampipeconfig/modconfig/dashboard_flow.go b/pkg/steampipeconfig/modconfig/dashboard_flow.go index 775c3d426..9c21380a9 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_flow.go +++ b/pkg/steampipeconfig/modconfig/dashboard_flow.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/hashicorp/hcl/v2" typehelpers "github.com/turbot/go-kit/types" "github.com/turbot/steampipe/pkg/utils" @@ -69,7 +70,7 @@ func (f *DashboardFlow) OnDecoded(block *hcl.Block, resourceMapProvider Resource if len(f.Edges) > 0 { f.EdgeNames = f.Edges.Names() } - return nil + return f.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } // TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926 diff --git a/pkg/steampipeconfig/modconfig/dashboard_graph.go b/pkg/steampipeconfig/modconfig/dashboard_graph.go index 69428597d..72b5d0c96 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_graph.go +++ b/pkg/steampipeconfig/modconfig/dashboard_graph.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/hashicorp/hcl/v2" typehelpers "github.com/turbot/go-kit/types" "github.com/turbot/steampipe/pkg/utils" @@ -71,7 +72,7 @@ func (g *DashboardGraph) OnDecoded(block *hcl.Block, resourceMapProvider Resourc if len(g.Edges) > 0 { g.EdgeNames = g.Edges.Names() } - return nil + return g.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } // TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926 diff --git a/pkg/steampipeconfig/modconfig/dashboard_hierarchy.go b/pkg/steampipeconfig/modconfig/dashboard_hierarchy.go index afcfc738d..a4ee0d9eb 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_hierarchy.go +++ b/pkg/steampipeconfig/modconfig/dashboard_hierarchy.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/zclconf/go-cty/cty" "github.com/hashicorp/hcl/v2" @@ -71,7 +72,7 @@ func (h *DashboardHierarchy) OnDecoded(block *hcl.Block, resourceMapProvider Res if len(h.Edges) > 0 { h.EdgeNames = h.Edges.Names() } - return nil + return h.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } // TODO [node_reuse] Add DashboardLeafNodeImpl and move this there https://github.com/turbot/steampipe/issues/2926 diff --git a/pkg/steampipeconfig/modconfig/dashboard_image.go b/pkg/steampipeconfig/modconfig/dashboard_image.go index fc8dea1ae..648f2c16e 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_image.go +++ b/pkg/steampipeconfig/modconfig/dashboard_image.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/zclconf/go-cty/cty" "github.com/hashicorp/hcl/v2" @@ -56,7 +57,7 @@ func (i *DashboardImage) Equals(other *DashboardImage) bool { // OnDecoded implements HclResource func (i *DashboardImage) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { i.setBaseProperties() - return nil + return i.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } func (i *DashboardImage) Diff(other *DashboardImage) *DashboardTreeItemDiffs { diff --git a/pkg/steampipeconfig/modconfig/dashboard_input.go b/pkg/steampipeconfig/modconfig/dashboard_input.go index e1b3c538e..2f0336482 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_input.go +++ b/pkg/steampipeconfig/modconfig/dashboard_input.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/zclconf/go-cty/cty" "github.com/hashicorp/hcl/v2" @@ -81,9 +82,9 @@ func (i *DashboardInput) Equals(other *DashboardInput) bool { } // OnDecoded implements HclResource -func (i *DashboardInput) OnDecoded(_ *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { +func (i *DashboardInput) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { i.setBaseProperties() - return nil + return i.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } func (i *DashboardInput) Diff(other *DashboardInput) *DashboardTreeItemDiffs { diff --git a/pkg/steampipeconfig/modconfig/dashboard_table.go b/pkg/steampipeconfig/modconfig/dashboard_table.go index 4eb2b7e42..15fd140d4 100644 --- a/pkg/steampipeconfig/modconfig/dashboard_table.go +++ b/pkg/steampipeconfig/modconfig/dashboard_table.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/turbot/steampipe/pkg/utils" "github.com/zclconf/go-cty/cty" @@ -89,7 +90,7 @@ func (t *DashboardTable) Equals(other *DashboardTable) bool { } // OnDecoded implements HclResource -func (t *DashboardTable) OnDecoded(_ *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { +func (t *DashboardTable) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { t.setBaseProperties() // populate columns map if len(t.ColumnList) > 0 { @@ -98,7 +99,7 @@ func (t *DashboardTable) OnDecoded(_ *hcl.Block, resourceMapProvider ResourceMap t.Columns[c.Name] = c } } - return nil + return t.QueryProviderImpl.OnDecoded(block, resourceMapProvider) } func (t *DashboardTable) Diff(other *DashboardTable) *DashboardTreeItemDiffs { diff --git a/pkg/steampipeconfig/modconfig/hcl_resource_impl.go b/pkg/steampipeconfig/modconfig/hcl_resource_impl.go index c0b9bbd69..204ab12d9 100644 --- a/pkg/steampipeconfig/modconfig/hcl_resource_impl.go +++ b/pkg/steampipeconfig/modconfig/hcl_resource_impl.go @@ -11,7 +11,7 @@ type HclResourceImpl struct { // required to allow partial decoding HclResourceRemain hcl.Body `hcl:",remain" json:"-"` - FullName string `cty:"name" json:"-"` + FullName string `cty:"name" column:"qualified_name,text" json:"-"` Title *string `cty:"title" hcl:"title" column:"title,text" json:"-"` ShortName string `cty:"short_name" hcl:"name,label" json:"name"` UnqualifiedName string `cty:"unqualified_name" json:"-"` diff --git a/pkg/steampipeconfig/modconfig/query_provider_impl.go b/pkg/steampipeconfig/modconfig/query_provider_impl.go index 372d3ce57..ea556829a 100644 --- a/pkg/steampipeconfig/modconfig/query_provider_impl.go +++ b/pkg/steampipeconfig/modconfig/query_provider_impl.go @@ -2,6 +2,7 @@ package modconfig import ( "fmt" + "github.com/hashicorp/hcl/v2" "github.com/turbot/go-kit/helpers" typehelpers "github.com/turbot/go-kit/types" @@ -12,10 +13,11 @@ type QueryProviderImpl struct { RuntimeDependencyProviderImpl QueryProviderRemain hcl.Body `hcl:",remain" json:"-"` - SQL *string `cty:"sql" hcl:"sql" column:"sql,text" json:"-"` - Query *Query `cty:"query" hcl:"query" json:"-"` - Args *QueryArgs `cty:"args" column:"args,jsonb" json:"-"` - Params []*ParamDef `cty:"params" column:"params,jsonb" json:"-"` + SQL *string `cty:"sql" hcl:"sql" column:"sql,text" json:"-"` + Query *Query `cty:"query" hcl:"query" json:"-"` + Args *QueryArgs `cty:"args" column:"args,jsonb" json:"-"` + Params []*ParamDef `cty:"params" column:"params,jsonb" json:"-"` + QueryName *string `column:"query,text" json:"-"` withs []*DashboardWith disableCtySerialise bool @@ -170,3 +172,15 @@ func (q *QueryProviderImpl) setBaseProperties() { func (q *QueryProviderImpl) getBaseImpl() *QueryProviderImpl { return q.base.(QueryProvider).GetQueryProviderImpl() } + +func (q *QueryProviderImpl) OnDecoded(block *hcl.Block, resourceMapProvider ResourceMapsProvider) hcl.Diagnostics { + q.populateQueryName() + + return nil +} + +func (q *QueryProviderImpl) populateQueryName() { + if q.Query != nil { + q.QueryName = &q.Query.FullName + } +} diff --git a/pkg/utils/string_slice.go b/pkg/utils/string_slice.go index de75651d3..b9d6517d8 100644 --- a/pkg/utils/string_slice.go +++ b/pkg/utils/string_slice.go @@ -17,3 +17,9 @@ func UnquoteStringArray(stringArray []string) []string { func StringSlicesEqual(l, r []string) bool { return strings.Join(l, ",") == strings.Join(r, ",") } + +// RemoveElementFromSlice takes a slice of strings and an index to remove, +// and returns a new slice with the specified element removed. +func RemoveElementFromSlice(slice []string, s int) []string { + return append(slice[:s], slice[s+1:]...) +} diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_benchmark.json b/tests/acceptance/test_data/templates/expected_introspection_info_benchmark.json index 7ec04dc66..b9fe399c8 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_benchmark.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_benchmark.json @@ -15,6 +15,7 @@ "introspection_table_mod.benchmark.sample_benchmark_1" ] ], + "qualified_name": "introspection_table_mod.benchmark.sample_benchmark_1", "resource_name": "sample_benchmark_1", "source_definition": "benchmark \"sample_benchmark_1\" {\n\ttitle = \"Sample benchmark 1\"\n\tdescription = \"Sample benchmark to test introspection functionality\"\n\tchildren = [\n\t\tcontrol.sample_control_1\n\t]\n}", "start_line_number": 35, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_control.json b/tests/acceptance/test_data/templates/expected_introspection_info_control.json index c1f31a1b9..d0524c1f2 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_control.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_control.json @@ -18,6 +18,8 @@ "introspection_table_mod.control.sample_control_1" ] ], + "qualified_name": "introspection_table_mod.control.sample_control_1", + "query": "introspection_table_mod.query.sample_query_1", "resource_name": "sample_control_1", "severity": "high", "source_definition": "control \"sample_control_1\" {\n title = \"Sample control 1\"\n description = \"Sample control to test introspection functionality\"\n query = query.sample_query_1\n severity = \"high\"\n tags = {\n \"foo\": \"bar\"\n }\n}", diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard.json index be3819775..32290fd01 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard.json @@ -22,6 +22,7 @@ "introspection_table_mod.dashboard.sample_dashboard_1" ] ], + "qualified_name": "introspection_table_mod.dashboard.sample_dashboard_1", "resource_name": "sample_dashboard_1", "source_definition": "dashboard \"sample_dashboard_1\" {\n title = \"Sample dashboard 1\"\n description = \"Sample dashboard to test introspection functionality\"\n\n container \"sample_conatiner_1\" {\n\t\tcard \"sample_card_1\" {\n\t\t\ttitle = \"Sample card 1\"\n\t\t}\n\n\t\timage \"sample_image_1\" {\n\t\t\ttitle = \"Sample image 1\"\n\t\t\twidth = 3\n \t\tsrc = \"https://steampipe.io/images/logo.png\"\n \t\talt = \"steampipe\"\n\t\t}\n\n\t\ttext \"sample_text_1\" {\n\t\t\ttitle = \"Sample text 1\"\n\t\t}\n\n chart \"sample_chart_1\" {\n sql = \"select 1 as chart\"\n width = 5\n title = \"Sample chart 1\"\n }\n\n flow \"sample_flow_1\" {\n title = \"Sample flow 1\"\n width = 3\n\n node \"sample_node_1\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_1\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }\n\n graph \"sample_graph_1\" {\n title = \"Sample graph 1\"\n width = 5\n\n node \"sample_node_2\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_2\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }\n\n hierarchy \"sample_hierarchy_1\" {\n title = \"Sample hierarchy 1\"\n width = 5\n\n node \"sample_node_3\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_3\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }\n\n table \"sample_table_1\" {\n sql = \"select 1 as table\"\n width = 4\n title = \"Sample table 1\"\n }\n\n input \"sample_input_1\" {\n sql = \"select 1 as input\"\n width = 2\n title = \"Sample input 1\"\n }\n }\n}", "start_line_number": 43, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_card.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_card.json index 40f5296ad..54e7c38fc 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_card.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_card.json @@ -18,6 +18,8 @@ "introspection_table_mod.text.sample_text_1" ] ], + "qualified_name": "introspection_table_mod.card.sample_card_1", + "query": null, "resource_name": "sample_card_1", "source_definition": "\t\tcard \"sample_card_1\" {\n\t\t\ttitle = \"Sample card 1\"\n\t\t}", "sql": null, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_chart.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_chart.json index 155ff7d38..ee592920d 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_chart.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_chart.json @@ -18,6 +18,8 @@ "introspection_table_mod.text.sample_text_1" ] ], + "qualified_name": "introspection_table_mod.chart.sample_chart_1", + "query": null, "resource_name": "sample_chart_1", "series": null, "source_definition": " chart \"sample_chart_1\" {\n sql = \"select 1 as chart\"\n width = 5\n title = \"Sample chart 1\"\n }", diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_flow.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_flow.json index d9ba52c4d..9a6380872 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_flow.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_flow.json @@ -19,6 +19,8 @@ ], "params": null, "path": null, + "qualified_name": "introspection_table_mod.flow.sample_flow_1", + "query": null, "resource_name": "sample_flow_1", "source_definition": " flow \"sample_flow_1\" {\n title = \"Sample flow 1\"\n width = 3\n\n node \"sample_node_1\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_1\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }", "sql": null, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_graph.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_graph.json index d49292c4d..bce5076b6 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_graph.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_graph.json @@ -20,6 +20,8 @@ ], "params": null, "path": null, + "qualified_name": "introspection_table_mod.graph.sample_graph_1", + "query": null, "resource_name": "sample_graph_1", "source_definition": " graph \"sample_graph_1\" {\n title = \"Sample graph 1\"\n width = 5\n\n node \"sample_node_2\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_2\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }", "sql": null, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_hierarchy.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_hierarchy.json index 8ddcc07b9..1ac95cd95 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_hierarchy.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_hierarchy.json @@ -19,6 +19,8 @@ ], "params": null, "path": null, + "qualified_name": "introspection_table_mod.hierarchy.sample_hierarchy_1", + "query": null, "resource_name": "sample_hierarchy_1", "source_definition": " hierarchy \"sample_hierarchy_1\" {\n title = \"Sample hierarchy 1\"\n width = 5\n\n node \"sample_node_3\" {\n sql = <<-EOQ\n select 1 as node\n EOQ\n }\n edge \"sample_edge_3\" {\n sql = <<-EOQ\n select 1 as edge\n EOQ\n }\n }", "sql": null, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_image.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_image.json index 099f9b65c..8376bbe3f 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_image.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_image.json @@ -17,6 +17,8 @@ "introspection_table_mod.text.sample_text_1" ] ], + "qualified_name": "introspection_table_mod.image.sample_image_1", + "query": null, "resource_name": "sample_image_1", "source_definition": "\t\timage \"sample_image_1\" {\n\t\t\ttitle = \"Sample image 1\"\n\t\t\twidth = 3\n \t\tsrc = \"https://steampipe.io/images/logo.png\"\n \t\talt = \"steampipe\"\n\t\t}", "sql": null, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_input.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_input.json index 98b4fe76c..6eee89e42 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_input.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_input.json @@ -19,6 +19,8 @@ ] ], "placeholder": null, + "qualified_name": "introspection_table_mod.input.sample_input_1", + "query": null, "resource_name": "sample_input_1", "source_definition": " input \"sample_input_1\" {\n sql = \"select 1 as input\"\n width = 2\n title = \"Sample input 1\"\n }", "sql": "select 1 as input", diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_table.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_table.json index 19836d214..32434de8d 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_table.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_table.json @@ -17,6 +17,8 @@ "introspection_table_mod.text.sample_text_1" ] ], + "qualified_name": "introspection_table_mod.table.sample_table_1", + "query": null, "resource_name": "sample_table_1", "source_definition": " table \"sample_table_1\" {\n sql = \"select 1 as table\"\n width = 4\n title = \"Sample table 1\"\n }", "sql": "select 1 as table", diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_text.json b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_text.json index 675d071d3..81d420763 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_text.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_dashboard_text.json @@ -14,6 +14,7 @@ "introspection_table_mod.text.sample_text_1" ] ], + "qualified_name": "introspection_table_mod.text.sample_text_1", "resource_name": "sample_text_1", "source_definition": "\t\ttext \"sample_text_1\" {\n\t\t\ttitle = \"Sample text 1\"\n\t\t}", "start_line_number": 59, diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_query.json b/tests/acceptance/test_data/templates/expected_introspection_info_query.json index 5a7e811e8..006f4b079 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_query.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_query.json @@ -30,6 +30,7 @@ "introspection_table_mod.query.sample_query_1" ] ], + "qualified_name": "introspection_table_mod.query.sample_query_1", "resource_name": "sample_query_1", "source_definition": "query \"sample_query_1\"{\n\ttitle =\"Sample query 1\"\n\tdescription = \"query 1 - 3 params all with defaults\"\n\tsql = \"select 'ok' as status, 'steampipe' as resource, concat($1::text, $2::text, $3::text) as reason\"\n\tparam \"p1\"{\n\t\t\tdescription = \"p1\"\n\t\t\tdefault = var.sample_var_1\n\t}\n\tparam \"p2\"{\n\t\t\tdescription = \"p2\"\n\t\t\tdefault = \"because_def \"\n\t}\n\tparam \"p3\"{\n\t\t\tdescription = \"p3\"\n\t\t\tdefault = \"string\"\n\t}\n}", "sql": "select 'ok' as status, 'steampipe' as resource, concat($1::text, $2::text, $3::text) as reason", diff --git a/tests/acceptance/test_data/templates/expected_introspection_info_variable.json b/tests/acceptance/test_data/templates/expected_introspection_info_variable.json index 37f515df5..1e464c834 100644 --- a/tests/acceptance/test_data/templates/expected_introspection_info_variable.json +++ b/tests/acceptance/test_data/templates/expected_introspection_info_variable.json @@ -21,6 +21,7 @@ "introspection_table_mod.var.sample_var_1" ] ], + "qualified_name": "introspection_table_mod.var.sample_var_1", "resource_name": "sample_var_1", "source_definition": "variable \"sample_var_1\"{\n\ttype = string\n\tdefault = \"steampipe_var\"\n}", "start_line_number": 1, diff --git a/tests/acceptance/test_files/introspection.bats b/tests/acceptance/test_files/introspection.bats index 573ae1e4c..8ca43aab5 100644 --- a/tests/acceptance/test_files/introspection.bats +++ b/tests/acceptance/test_files/introspection.bats @@ -52,10 +52,10 @@ load "$LIB_BATS_SUPPORT/load.bash" # removing the 8th line, since it contains file location which would differ in github runners if [[ "$OSTYPE" == "darwin"* ]]; then run sed -i ".json" "8d" output.json - run sed -i ".json" "32d" output.json + run sed -i ".json" "33d" output.json else run sed -i "8d" output.json - run sed -i "32d" output.json + run sed -i "33d" output.json fi assert_equal "$(cat output.json)" "$(cat $TEST_DATA_DIR/expected_introspection_info_variable.json)"