From a2bb72fb87087e5a41b4c90ae631b6f843dca9c5 Mon Sep 17 00:00:00 2001 From: kmoe <5575356+kmoe@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:41:07 +0000 Subject: [PATCH] graph: update format for v1.7 (#424) --- tfexec/graph.go | 2 +- tfexec/internal/e2etest/graph_test.go | 14 ++++++++++++-- tfexec/internal/e2etest/providers_schema_test.go | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tfexec/graph.go b/tfexec/graph.go index 1b28aa57..0f8b0eee 100644 --- a/tfexec/graph.go +++ b/tfexec/graph.go @@ -60,7 +60,7 @@ func (tf *Terraform) graphCmd(ctx context.Context, opts ...GraphOption) (*exec.C args := []string{"graph"} if c.plan != "" { - // plan was a positional arguement prior to Terraform 0.15.0. Ensure proper use by checking version. + // plan was a positional argument prior to Terraform 0.15.0. Ensure proper use by checking version. if err := tf.compatible(ctx, tf0_15_0, nil); err == nil { args = append(args, "-plan="+c.plan) } else { diff --git a/tfexec/internal/e2etest/graph_test.go b/tfexec/internal/e2etest/graph_test.go index 715e189d..aea432f5 100644 --- a/tfexec/internal/e2etest/graph_test.go +++ b/tfexec/internal/e2etest/graph_test.go @@ -96,8 +96,9 @@ func expectedGraphOutput(tfv *version.Version) string { ` } - // 1.1.0+ - return `digraph { + if v.GreaterThanOrEqual(v1_1) && v.LessThan(v1_7) { + // 1.1.0 - 1.7.0 + return `digraph { compound = "true" newrank = "true" subgraph "root" { @@ -109,5 +110,14 @@ func expectedGraphOutput(tfv *version.Version) string { } } +` + } + + // 1.7.0+ + return `digraph G { + rankdir = "RL"; + node [shape = rect, fontname = "sans-serif"]; + "null_resource.foo" [label="null_resource.foo"]; +} ` } diff --git a/tfexec/internal/e2etest/providers_schema_test.go b/tfexec/internal/e2etest/providers_schema_test.go index 97979fc3..cafce807 100644 --- a/tfexec/internal/e2etest/providers_schema_test.go +++ b/tfexec/internal/e2etest/providers_schema_test.go @@ -22,6 +22,7 @@ var ( v0_15_0 = version.Must(version.NewVersion("0.15.0")) v1_0 = version.Must(version.NewVersion("1.0.0")) v1_1 = version.Must(version.NewVersion("1.1.0")) + v1_7 = version.Must(version.NewVersion("1.7.0")) ) func TestProvidersSchema(t *testing.T) {