From afeb8e10b7f9477698f6b5a27ad6f7c62d85f75e Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 26 Jan 2026 10:53:36 -0700 Subject: [PATCH] expand regex to account for new list declarations --- lib/blocks/blockreader.go | 6 +++--- lib/blocks/blockreader_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/blocks/blockreader.go b/lib/blocks/blockreader.go index b851bc69..c563d963 100644 --- a/lib/blocks/blockreader.go +++ b/lib/blocks/blockreader.go @@ -113,12 +113,12 @@ func (bv blockVisitor) Visit(cursor *astutil.Cursor) bool { return true } -// Includes matching Go format verbs in the resource, data source, variable, or output name. +// Includes matching Go format verbs in the resource, data source, list, variable, or output name. // Technically, this is only valid for the Go matcher, but included generally for simplicity. -var terraformMatcher = regexp.MustCompile(`(((resource|data)\s+"[-a-z0-9_]+")|(variable|output))\s+"[-a-zA-Z0-9_%\[\]]+"\s+\{`) +var terraformMatcher = regexp.MustCompile(`(((resource|data|list)\s+"[-a-z0-9_]+")|(variable|output))\s+"[-a-zA-Z0-9_%\[\]]+"\s+\{`) // A simple check to see if the content looks like a Terraform configuration. -// Looks for a line with either a resource, data source, variable, or output declaration +// Looks for a line with either a resource, data source, list, variable, or output declaration func looksLikeTerraform(s string) bool { return terraformMatcher.MatchString(s) } diff --git a/lib/blocks/blockreader_test.go b/lib/blocks/blockreader_test.go index aa6efa66..8363d63c 100644 --- a/lib/blocks/blockreader_test.go +++ b/lib/blocks/blockreader_test.go @@ -332,6 +332,18 @@ data "aws_s3_bucket" "simple-data" { }, { text: ` +list "azurerm_resource_group" "example" { + provider = azurerm + + config { + filter = "tagName eq 'query' and tagValue eq 'example'" + } +} +`, + expected: true, + }, + { + text: ` variable "name" { type = string }`,