From 89142aa0090a3a999709f73597837571602f305a Mon Sep 17 00:00:00 2001 From: James Pogran Date: Thu, 10 Aug 2023 14:42:34 -0400 Subject: [PATCH 01/15] Implement reference validation Add the ability to use the collected origin and target references in early validation. Validation funcs will be provided by terraform-ls for now. --- internal/decoder/decoder.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/decoder/decoder.go b/internal/decoder/decoder.go index e951e7cf..6d315376 100644 --- a/internal/decoder/decoder.go +++ b/internal/decoder/decoder.go @@ -7,6 +7,7 @@ import ( "context" "github.com/hashicorp/hcl-lang/decoder" + "github.com/hashicorp/hcl-lang/lang" "github.com/hashicorp/hcl-lang/reference" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/terraform-ls/internal/codelens" @@ -91,5 +92,41 @@ func DecoderContext(ctx context.Context) decoder.DecoderContext { } } + // TODO: extract out of this file + dCtx.Validations = append(dCtx.Validations, func(ctx context.Context) lang.DiagnosticsMap { + // get files from pathContext + //iterate over files and validate + pathCtx, err := decoder.PathCtx(ctx) + if err != nil { + // TODO + } + + diagsMap := make(lang.DiagnosticsMap) + + for _, origin := range pathCtx.ReferenceOrigins { + matchableOrigin, ok := origin.(reference.MatchableOrigin) + if !ok { + // TODO: add a diag here + continue + } + + _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) + if !ok { + // target not found + diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No reference found", // TODO: Is there more we can state here? + Subject: origin.OriginRange().Ptr(), + }, + } + continue + } + + } + + return diagsMap + }) + return dCtx } From ede66477a1be92a19b794f4c435c54c181d8c673 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Fri, 11 Aug 2023 12:40:03 -0400 Subject: [PATCH 02/15] extract to file --- internal/decoder/decoder.go | 39 ++--------------- internal/decoder/validations/validations.go | 47 +++++++++++++++++++++ 2 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 internal/decoder/validations/validations.go diff --git a/internal/decoder/decoder.go b/internal/decoder/decoder.go index 6d315376..1d2b8d90 100644 --- a/internal/decoder/decoder.go +++ b/internal/decoder/decoder.go @@ -7,10 +7,10 @@ import ( "context" "github.com/hashicorp/hcl-lang/decoder" - "github.com/hashicorp/hcl-lang/lang" "github.com/hashicorp/hcl-lang/reference" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/terraform-ls/internal/codelens" + "github.com/hashicorp/terraform-ls/internal/decoder/validations" ilsp "github.com/hashicorp/terraform-ls/internal/lsp" lsp "github.com/hashicorp/terraform-ls/internal/protocol" "github.com/hashicorp/terraform-ls/internal/state" @@ -92,41 +92,8 @@ func DecoderContext(ctx context.Context) decoder.DecoderContext { } } - // TODO: extract out of this file - dCtx.Validations = append(dCtx.Validations, func(ctx context.Context) lang.DiagnosticsMap { - // get files from pathContext - //iterate over files and validate - pathCtx, err := decoder.PathCtx(ctx) - if err != nil { - // TODO - } - - diagsMap := make(lang.DiagnosticsMap) - - for _, origin := range pathCtx.ReferenceOrigins { - matchableOrigin, ok := origin.(reference.MatchableOrigin) - if !ok { - // TODO: add a diag here - continue - } - - _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) - if !ok { - // target not found - diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ - &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "No reference found", // TODO: Is there more we can state here? - Subject: origin.OriginRange().Ptr(), - }, - } - continue - } - - } - - return diagsMap - }) + validations := validations.ValidationFuncs() + dCtx.Validations = append(dCtx.Validations, validations...) return dCtx } diff --git a/internal/decoder/validations/validations.go b/internal/decoder/validations/validations.go new file mode 100644 index 00000000..61bdc48d --- /dev/null +++ b/internal/decoder/validations/validations.go @@ -0,0 +1,47 @@ +package validations + +import ( + "context" + + "github.com/hashicorp/hcl-lang/decoder" + "github.com/hashicorp/hcl-lang/lang" + "github.com/hashicorp/hcl-lang/reference" + "github.com/hashicorp/hcl/v2" +) + +func ValidationFuncs() []lang.ValidationFunc { + return []lang.ValidationFunc{ + func(ctx context.Context) lang.DiagnosticsMap { + pathCtx, err := decoder.PathCtx(ctx) + if err != nil { + // TODO + } + + diagsMap := make(lang.DiagnosticsMap) + + for _, origin := range pathCtx.ReferenceOrigins { + matchableOrigin, ok := origin.(reference.MatchableOrigin) + if !ok { + // TODO: add a diag here + continue + } + + _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) + if !ok { + // target not found + diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No reference found", // TODO: Is there more we can state here? + Subject: origin.OriginRange().Ptr(), + }, + } + continue + } + + } + + return diagsMap + }, + } +} From 85d39dd4e1197b1ffdf16636305574fe3cb1a0d9 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Tue, 15 Aug 2023 12:35:44 -0400 Subject: [PATCH 03/15] extract and test --- internal/decoder/decoder.go | 5 +- .../validations/unreferenced_origin.go | 43 +++++++++++++++++ .../validations/unreferenced_origin_test.go | 44 +++++++++++++++++ internal/decoder/validations/validations.go | 47 ------------------- 4 files changed, 91 insertions(+), 48 deletions(-) create mode 100644 internal/decoder/validations/unreferenced_origin.go create mode 100644 internal/decoder/validations/unreferenced_origin_test.go delete mode 100644 internal/decoder/validations/validations.go diff --git a/internal/decoder/decoder.go b/internal/decoder/decoder.go index 1d2b8d90..6fd0d8f2 100644 --- a/internal/decoder/decoder.go +++ b/internal/decoder/decoder.go @@ -7,6 +7,7 @@ import ( "context" "github.com/hashicorp/hcl-lang/decoder" + "github.com/hashicorp/hcl-lang/lang" "github.com/hashicorp/hcl-lang/reference" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/terraform-ls/internal/codelens" @@ -92,7 +93,9 @@ func DecoderContext(ctx context.Context) decoder.DecoderContext { } } - validations := validations.ValidationFuncs() + validations := []lang.ValidationFunc{ + validations.UnReferencedOrigin, + } dCtx.Validations = append(dCtx.Validations, validations...) return dCtx diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go new file mode 100644 index 00000000..521f1e3a --- /dev/null +++ b/internal/decoder/validations/unreferenced_origin.go @@ -0,0 +1,43 @@ +package validations + +import ( + "context" + + "github.com/hashicorp/hcl-lang/decoder" + "github.com/hashicorp/hcl-lang/lang" + "github.com/hashicorp/hcl-lang/reference" + "github.com/hashicorp/hcl/v2" +) + +func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { + pathCtx, err := decoder.PathCtx(ctx) + if err != nil { + // TODO + } + + diagsMap := make(lang.DiagnosticsMap) + + for _, origin := range pathCtx.ReferenceOrigins { + matchableOrigin, ok := origin.(reference.MatchableOrigin) + if !ok { + // TODO: add a diag here + continue + } + + _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) + if !ok { + // target not found + diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No reference found", // TODO: Is there more we can state here? + Subject: origin.OriginRange().Ptr(), + }, + } + continue + } + + } + + return diagsMap +} diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go new file mode 100644 index 00000000..2f2dfecc --- /dev/null +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -0,0 +1,44 @@ +package validations + +import ( + "context" + "reflect" + "testing" + + "github.com/hashicorp/hcl-lang/lang" + "github.com/hashicorp/hcl/v2" +) + +func TestUnReferencedOrigin(t *testing.T) { + ctx := context.Background() + // build pathdecoder + // set pathctx + // ctx = withPathContext(ctx, d.pathCtx) + + tests := []struct { + name string + ctx context.Context + want lang.DiagnosticsMap + }{ + { + name: "unreferenced variable", + ctx: ctx, + want: lang.DiagnosticsMap{ + "test.tf": hcl.Diagnostics{ + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No reference found", + Subject: &hcl.Range{}, + }, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := UnReferencedOrigin(tt.ctx); !reflect.DeepEqual(got, tt.want) { + t.Errorf("UnReferencedOrigin() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/decoder/validations/validations.go b/internal/decoder/validations/validations.go deleted file mode 100644 index 61bdc48d..00000000 --- a/internal/decoder/validations/validations.go +++ /dev/null @@ -1,47 +0,0 @@ -package validations - -import ( - "context" - - "github.com/hashicorp/hcl-lang/decoder" - "github.com/hashicorp/hcl-lang/lang" - "github.com/hashicorp/hcl-lang/reference" - "github.com/hashicorp/hcl/v2" -) - -func ValidationFuncs() []lang.ValidationFunc { - return []lang.ValidationFunc{ - func(ctx context.Context) lang.DiagnosticsMap { - pathCtx, err := decoder.PathCtx(ctx) - if err != nil { - // TODO - } - - diagsMap := make(lang.DiagnosticsMap) - - for _, origin := range pathCtx.ReferenceOrigins { - matchableOrigin, ok := origin.(reference.MatchableOrigin) - if !ok { - // TODO: add a diag here - continue - } - - _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) - if !ok { - // target not found - diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ - &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "No reference found", // TODO: Is there more we can state here? - Subject: origin.OriginRange().Ptr(), - }, - } - continue - } - - } - - return diagsMap - }, - } -} From 358f40efc6bbc96e9a57cfcc104cdc356cb5351b Mon Sep 17 00:00:00 2001 From: "hashicorp-copywrite[bot]" <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 16:36:50 +0000 Subject: [PATCH 04/15] [COMPLIANCE] Add required copyright headers Signed-off-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> --- internal/decoder/validations/unreferenced_origin.go | 3 +++ internal/decoder/validations/unreferenced_origin_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 521f1e3a..2c4497fd 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package validations import ( diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 2f2dfecc..f8970eb4 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package validations import ( From cb444088e99520c09626f3353882541ea2354a69 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 10:57:51 -0400 Subject: [PATCH 05/15] only inspect variables --- .../validations/unreferenced_origin.go | 14 ++++++++-- .../validations/unreferenced_origin_test.go | 28 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 2c4497fd..55c7ca56 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -5,6 +5,8 @@ package validations import ( "context" + "fmt" + "log" "github.com/hashicorp/hcl-lang/decoder" "github.com/hashicorp/hcl-lang/lang" @@ -23,17 +25,23 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { for _, origin := range pathCtx.ReferenceOrigins { matchableOrigin, ok := origin.(reference.MatchableOrigin) if !ok { - // TODO: add a diag here continue } + foo := matchableOrigin.Address()[0] + if foo.String() != "var" { + continue + } + + log.Printf("MatchableOrigin: %s", matchableOrigin.Address()) + _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) if !ok { // target not found diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ &hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: "No reference found", // TODO: Is there more we can state here? + Summary: fmt.Sprintf("No declaration found for %q", matchableOrigin.Address()), Subject: origin.OriginRange().Ptr(), }, } @@ -41,6 +49,6 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { } } - + log.Printf("Length: %d Diags produced: %+v", len(pathCtx.ReferenceOrigins) , diagsMap) return diagsMap } diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index f8970eb4..8de7f29d 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -8,15 +8,32 @@ import ( "reflect" "testing" + "github.com/hashicorp/hcl-lang/decoder" "github.com/hashicorp/hcl-lang/lang" + "github.com/hashicorp/hcl-lang/reference" "github.com/hashicorp/hcl/v2" ) func TestUnReferencedOrigin(t *testing.T) { ctx := context.Background() - // build pathdecoder - // set pathctx - // ctx = withPathContext(ctx, d.pathCtx) + + pathCtx := &decoder.PathContext{ + ReferenceOrigins: reference.Origins{ + reference.LocalOrigin{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{}, + End: hcl.Pos{}, + }, + Addr: lang.Address{ + lang.RootStep{Name: "var"}, + lang.AttrStep{Name: "foo"}, + }, + }, + }, + } + + ctx = decoder.WithPathContext(ctx, pathCtx) tests := []struct { name string @@ -24,19 +41,20 @@ func TestUnReferencedOrigin(t *testing.T) { want lang.DiagnosticsMap }{ { - name: "unreferenced variable", + name: "undeclared variable", ctx: ctx, want: lang.DiagnosticsMap{ "test.tf": hcl.Diagnostics{ &hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: "No reference found", + Summary: "No declaration found for \"var.foo\"", Subject: &hcl.Range{}, }, }, }, }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := UnReferencedOrigin(tt.ctx); !reflect.DeepEqual(got, tt.want) { From f0576336afaa83bec01232065434306559558312 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 11:21:47 -0400 Subject: [PATCH 06/15] tests --- .../validations/unreferenced_origin.go | 10 +- .../validations/unreferenced_origin_test.go | 112 +++++++++++++----- 2 files changed, 89 insertions(+), 33 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 55c7ca56..09e4f0a3 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -6,7 +6,6 @@ package validations import ( "context" "fmt" - "log" "github.com/hashicorp/hcl-lang/decoder" "github.com/hashicorp/hcl-lang/lang" @@ -15,12 +14,13 @@ import ( ) func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { + diagsMap := make(lang.DiagnosticsMap) + pathCtx, err := decoder.PathCtx(ctx) if err != nil { - // TODO + return diagsMap } - diagsMap := make(lang.DiagnosticsMap) for _, origin := range pathCtx.ReferenceOrigins { matchableOrigin, ok := origin.(reference.MatchableOrigin) @@ -33,8 +33,6 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { continue } - log.Printf("MatchableOrigin: %s", matchableOrigin.Address()) - _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) if !ok { // target not found @@ -49,6 +47,6 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { } } - log.Printf("Length: %d Diags produced: %+v", len(pathCtx.ReferenceOrigins) , diagsMap) + return diagsMap } diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 8de7f29d..68348e7a 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -5,9 +5,10 @@ package validations import ( "context" - "reflect" + "fmt" "testing" + "github.com/google/go-cmp/cmp" "github.com/hashicorp/hcl-lang/decoder" "github.com/hashicorp/hcl-lang/lang" "github.com/hashicorp/hcl-lang/reference" @@ -15,26 +16,6 @@ import ( ) func TestUnReferencedOrigin(t *testing.T) { - ctx := context.Background() - - pathCtx := &decoder.PathContext{ - ReferenceOrigins: reference.Origins{ - reference.LocalOrigin{ - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{}, - End: hcl.Pos{}, - }, - Addr: lang.Address{ - lang.RootStep{Name: "var"}, - lang.AttrStep{Name: "foo"}, - }, - }, - }, - } - - ctx = decoder.WithPathContext(ctx, pathCtx) - tests := []struct { name string ctx context.Context @@ -42,24 +23,101 @@ func TestUnReferencedOrigin(t *testing.T) { }{ { name: "undeclared variable", - ctx: ctx, + ctx: buildPathCtx(reference.Origins{ + reference.LocalOrigin{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{}, + End: hcl.Pos{}, + }, + Addr: lang.Address{ + lang.RootStep{Name: "var"}, + lang.AttrStep{Name: "foo"}, + }, + }, + }), want: lang.DiagnosticsMap{ "test.tf": hcl.Diagnostics{ &hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "No declaration found for \"var.foo\"", - Subject: &hcl.Range{}, + Subject: &hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{}, + End: hcl.Pos{}, + }, + }, + }, + }, + }, + { + name: "many undeclared variables", + ctx: buildPathCtx(reference.Origins{ + reference.LocalOrigin{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ Line: 1, Column: 1, Byte: 0 }, + End: hcl.Pos{ Line: 1, Column: 10, Byte: 10 }, + }, + Addr: lang.Address{ + lang.RootStep{Name: "var"}, + lang.AttrStep{Name: "foo"}, + }, + }, + reference.LocalOrigin{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ Line: 2, Column: 1, Byte: 0 }, + End: hcl.Pos{ Line: 2, Column: 10, Byte: 10 }, + }, + Addr: lang.Address{ + lang.RootStep{Name: "var"}, + lang.AttrStep{Name: "wakka"}, + }, + }, + }), + want: lang.DiagnosticsMap{ + "test.tf": hcl.Diagnostics{ + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No declaration found for \"var.foo\"", + Subject: &hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ Line: 1, Column: 1, Byte: 0 }, + End: hcl.Pos{ Line: 1, Column: 10, Byte: 10 }, + }, + }, + &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "No declaration found for \"var.wakka\"", + Subject: &hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ Line: 2, Column: 1, Byte: 0 }, + End: hcl.Pos{ Line: 2, Column: 10, Byte: 10 }, + }, }, }, }, }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := UnReferencedOrigin(tt.ctx); !reflect.DeepEqual(got, tt.want) { - t.Errorf("UnReferencedOrigin() = %v, want %v", got, tt.want) + for i, tt := range tests { + t.Run(fmt.Sprintf("%2d-%s", i, tt.name), func(t *testing.T) { + diags := UnReferencedOrigin(tt.ctx) + if diff := cmp.Diff(tt.want["test.tf"], diags["test.tf"]); diff != "" { + t.Fatalf("unexpected diagnostics: %s", diff) } }) } } + +func buildPathCtx(origins reference.Origins) context.Context { + ctx := context.Background() + + pathCtx := &decoder.PathContext{ + ReferenceOrigins: origins, + } + + ctx = decoder.WithPathContext(ctx, pathCtx) + return ctx +} From f9e74771eb01c6b7b5ec7bc8c346326bf3c38fc1 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 11:26:37 -0400 Subject: [PATCH 07/15] correctly handle multiple diags --- .../decoder/validations/unreferenced_origin.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 09e4f0a3..9a9e86d1 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -21,7 +21,6 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { return diagsMap } - for _, origin := range pathCtx.ReferenceOrigins { matchableOrigin, ok := origin.(reference.MatchableOrigin) if !ok { @@ -36,13 +35,14 @@ func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { _, ok = pathCtx.ReferenceTargets.Match(matchableOrigin) if !ok { // target not found - diagsMap[origin.OriginRange().Filename] = hcl.Diagnostics{ - &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("No declaration found for %q", matchableOrigin.Address()), - Subject: origin.OriginRange().Ptr(), - }, + fileName := origin.OriginRange().Filename + d := &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("No declaration found for %q", matchableOrigin.Address()), + Subject: origin.OriginRange().Ptr(), } + diagsMap[fileName] = diagsMap[fileName].Append(d) + continue } From c0a4beae6798a70020a305b0e157a633cfae9337 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 11:52:46 -0400 Subject: [PATCH 08/15] adjust test harness --- .../validations/unreferenced_origin_test.go | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 68348e7a..e0d9607b 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -18,12 +18,12 @@ import ( func TestUnReferencedOrigin(t *testing.T) { tests := []struct { name string - ctx context.Context + origins reference.Origins want lang.DiagnosticsMap }{ { name: "undeclared variable", - ctx: buildPathCtx(reference.Origins{ + origins: reference.Origins{ reference.LocalOrigin{ Range: hcl.Range{ Filename: "test.tf", @@ -35,7 +35,7 @@ func TestUnReferencedOrigin(t *testing.T) { lang.AttrStep{Name: "foo"}, }, }, - }), + }, want: lang.DiagnosticsMap{ "test.tf": hcl.Diagnostics{ &hcl.Diagnostic{ @@ -52,12 +52,12 @@ func TestUnReferencedOrigin(t *testing.T) { }, { name: "many undeclared variables", - ctx: buildPathCtx(reference.Origins{ + origins: reference.Origins{ reference.LocalOrigin{ Range: hcl.Range{ Filename: "test.tf", - Start: hcl.Pos{ Line: 1, Column: 1, Byte: 0 }, - End: hcl.Pos{ Line: 1, Column: 10, Byte: 10 }, + Start: hcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 1, Column: 10, Byte: 10}, }, Addr: lang.Address{ lang.RootStep{Name: "var"}, @@ -67,15 +67,15 @@ func TestUnReferencedOrigin(t *testing.T) { reference.LocalOrigin{ Range: hcl.Range{ Filename: "test.tf", - Start: hcl.Pos{ Line: 2, Column: 1, Byte: 0 }, - End: hcl.Pos{ Line: 2, Column: 10, Byte: 10 }, + Start: hcl.Pos{Line: 2, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 2, Column: 10, Byte: 10}, }, Addr: lang.Address{ lang.RootStep{Name: "var"}, lang.AttrStep{Name: "wakka"}, }, }, - }), + }, want: lang.DiagnosticsMap{ "test.tf": hcl.Diagnostics{ &hcl.Diagnostic{ @@ -83,8 +83,8 @@ func TestUnReferencedOrigin(t *testing.T) { Summary: "No declaration found for \"var.foo\"", Subject: &hcl.Range{ Filename: "test.tf", - Start: hcl.Pos{ Line: 1, Column: 1, Byte: 0 }, - End: hcl.Pos{ Line: 1, Column: 10, Byte: 10 }, + Start: hcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 1, Column: 10, Byte: 10}, }, }, &hcl.Diagnostic{ @@ -92,8 +92,8 @@ func TestUnReferencedOrigin(t *testing.T) { Summary: "No declaration found for \"var.wakka\"", Subject: &hcl.Range{ Filename: "test.tf", - Start: hcl.Pos{ Line: 2, Column: 1, Byte: 0 }, - End: hcl.Pos{ Line: 2, Column: 10, Byte: 10 }, + Start: hcl.Pos{Line: 2, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 2, Column: 10, Byte: 10}, }, }, }, @@ -103,21 +103,18 @@ func TestUnReferencedOrigin(t *testing.T) { for i, tt := range tests { t.Run(fmt.Sprintf("%2d-%s", i, tt.name), func(t *testing.T) { - diags := UnReferencedOrigin(tt.ctx) + ctx := context.Background() + + pathCtx := &decoder.PathContext{ + ReferenceOrigins: tt.origins, + } + + ctx = decoder.WithPathContext(ctx, pathCtx) + + diags := UnReferencedOrigin(ctx) if diff := cmp.Diff(tt.want["test.tf"], diags["test.tf"]); diff != "" { t.Fatalf("unexpected diagnostics: %s", diff) } }) } } - -func buildPathCtx(origins reference.Origins) context.Context { - ctx := context.Background() - - pathCtx := &decoder.PathContext{ - ReferenceOrigins: origins, - } - - ctx = decoder.WithPathContext(ctx, pathCtx) - return ctx -} From 64902e1f68a59bfca6fddcc441d51d04d837c879 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 11:53:23 -0400 Subject: [PATCH 09/15] formatting --- internal/decoder/validations/unreferenced_origin_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index e0d9607b..0604108a 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -17,9 +17,9 @@ import ( func TestUnReferencedOrigin(t *testing.T) { tests := []struct { - name string - origins reference.Origins - want lang.DiagnosticsMap + name string + origins reference.Origins + want lang.DiagnosticsMap }{ { name: "undeclared variable", From 775980d23bfd7261f8d2eabbea62ffb1cbd7024a Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:04:47 -0400 Subject: [PATCH 10/15] Apply suggestions from code review Co-authored-by: Radek Simko --- internal/decoder/validations/unreferenced_origin.go | 2 +- internal/decoder/validations/unreferenced_origin_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 9a9e86d1..6ca0ba27 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/hcl/v2" ) -func UnReferencedOrigin(ctx context.Context) lang.DiagnosticsMap { +func UnreferencedOrigins(ctx context.Context) lang.DiagnosticsMap { diagsMap := make(lang.DiagnosticsMap) pathCtx, err := decoder.PathCtx(ctx) diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 0604108a..8a5d8df5 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/hcl/v2" ) -func TestUnReferencedOrigin(t *testing.T) { +func TestUnreferencedOrigins(t *testing.T) { tests := []struct { name string origins reference.Origins From e19f6b57aafb8e92fdff5381579175be122c1b8d Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:07:45 -0400 Subject: [PATCH 11/15] Fix feedback --- internal/decoder/decoder.go | 2 +- internal/decoder/validations/unreferenced_origin_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/decoder/decoder.go b/internal/decoder/decoder.go index 6fd0d8f2..74247e4e 100644 --- a/internal/decoder/decoder.go +++ b/internal/decoder/decoder.go @@ -94,7 +94,7 @@ func DecoderContext(ctx context.Context) decoder.DecoderContext { } validations := []lang.ValidationFunc{ - validations.UnReferencedOrigin, + validations.UnreferencedOrigins, } dCtx.Validations = append(dCtx.Validations, validations...) diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 8a5d8df5..420d4f24 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -111,7 +111,7 @@ func TestUnreferencedOrigins(t *testing.T) { ctx = decoder.WithPathContext(ctx, pathCtx) - diags := UnReferencedOrigin(ctx) + diags := UnreferencedOrigins(ctx) if diff := cmp.Diff(tt.want["test.tf"], diags["test.tf"]); diff != "" { t.Fatalf("unexpected diagnostics: %s", diff) } From 6d204558766d63158777d2042be0a96e3cba84ef Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:21:14 -0400 Subject: [PATCH 12/15] feedback --- internal/decoder/validations/unreferenced_origin.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index 6ca0ba27..e233cf42 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -27,8 +27,11 @@ func UnreferencedOrigins(ctx context.Context) lang.DiagnosticsMap { continue } - foo := matchableOrigin.Address()[0] - if foo.String() != "var" { + // we only initially validate variables + // resources and data sources can have unknown schema + // and will be researched at a later point + firstStep := matchableOrigin.Address()[0] + if firstStep.String() != "var" { continue } From 0b508f9214d492e2a35bd14f56d4499acae879c6 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:25:10 -0400 Subject: [PATCH 13/15] feedback --- internal/decoder/validations/unreferenced_origin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index e233cf42..e8871153 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -24,6 +24,11 @@ func UnreferencedOrigins(ctx context.Context) lang.DiagnosticsMap { for _, origin := range pathCtx.ReferenceOrigins { matchableOrigin, ok := origin.(reference.MatchableOrigin) if !ok { + // we don't report on other origins to avoid complexity for now + // other origins would need to be matched against other + // modules/directories and we cannot be sure the targets are + // available within the workspace or were parsed/decoded/collected + // at the time this event occurs continue } From e04e8bf3ca7894fdf4f19fe2b3284a7880745cb4 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:33:39 -0400 Subject: [PATCH 14/15] Update hcl-lang reference --- go.mod | 2 +- go.sum | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 51cecd75..8122c514 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/hc-install v0.5.2 - github.com/hashicorp/hcl-lang v0.0.0-20230616080040-23442190b6b7 + github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816 github.com/hashicorp/hcl/v2 v2.17.0 github.com/hashicorp/terraform-exec v0.18.1 github.com/hashicorp/terraform-json v0.17.1 diff --git a/go.sum b/go.sum index 984827c0..acad97e5 100644 --- a/go.sum +++ b/go.sum @@ -109,6 +109,7 @@ github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0X github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -183,6 +184,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -208,8 +210,11 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl-lang v0.0.0-20230616080040-23442190b6b7 h1:tKk3jagIGu+0q/iUDLefzUfUmH0Txk+Cr0QXme33cBk= github.com/hashicorp/hcl-lang v0.0.0-20230616080040-23442190b6b7/go.mod h1:Y5G573YDt5m5HDSPMN3awPrpUjRLK6LucNYcd90RTI4= +github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816 h1:mJTyK9+yMLptuwhJba1Chnn5OSUtxo5FsQ++6xDipTs= +github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816/go.mod h1:xlYq00R/OYgpAmScjO1zkE9NCjl6zuMex1VVcUU0pjQ= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= @@ -239,6 +244,7 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/itchyny/gojq v0.12.11 h1:YhLueoHhHiN4mkfM+3AyJV6EPcCxKZsOnYf+aVSwaQw= github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -287,6 +293,7 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nightlyone/lockfile v1.0.0 h1:RHep2cFKK4PonZJDdEl4GmkabuhbsRMgk/k3uAmxBiA= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -313,6 +320,7 @@ github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -680,10 +688,12 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 11d66aa0cced0dc2be77cfc0933920331b0314bb Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 16 Aug 2023 14:35:10 -0400 Subject: [PATCH 15/15] Update hcl-lang reference --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 8122c514..afc0e797 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/hc-install v0.5.2 - github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816 + github.com/hashicorp/hcl-lang v0.0.0-20230816183022-371318075931 github.com/hashicorp/hcl/v2 v2.17.0 github.com/hashicorp/terraform-exec v0.18.1 github.com/hashicorp/terraform-json v0.17.1 diff --git a/go.sum b/go.sum index acad97e5..37458b4c 100644 --- a/go.sum +++ b/go.sum @@ -212,6 +212,8 @@ github.com/hashicorp/hcl-lang v0.0.0-20230616080040-23442190b6b7 h1:tKk3jagIGu+0 github.com/hashicorp/hcl-lang v0.0.0-20230616080040-23442190b6b7/go.mod h1:Y5G573YDt5m5HDSPMN3awPrpUjRLK6LucNYcd90RTI4= github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816 h1:mJTyK9+yMLptuwhJba1Chnn5OSUtxo5FsQ++6xDipTs= github.com/hashicorp/hcl-lang v0.0.0-20230810124751-5753e8194816/go.mod h1:xlYq00R/OYgpAmScjO1zkE9NCjl6zuMex1VVcUU0pjQ= +github.com/hashicorp/hcl-lang v0.0.0-20230816183022-371318075931 h1:l9TXEz7RJ6eOiXDQovcP0dZ6gruXQi/stbJYtpEKQII= +github.com/hashicorp/hcl-lang v0.0.0-20230816183022-371318075931/go.mod h1:xlYq00R/OYgpAmScjO1zkE9NCjl6zuMex1VVcUU0pjQ= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=