From 09a4f558ed592b384537f4992f197e4873652d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6nthal?= Date: Tue, 22 Feb 2022 23:01:07 +0100 Subject: [PATCH 1/2] add colors flag --- tfexec/apply.go | 2 +- tfexec/apply_test.go | 2 +- tfexec/cmd.go | 6 +++++- tfexec/destroy.go | 2 +- tfexec/destroy_test.go | 4 ++-- tfexec/fmt.go | 2 +- tfexec/get.go | 2 +- tfexec/get_test.go | 2 +- tfexec/graph_test.go | 4 ++++ tfexec/import.go | 2 +- tfexec/import_test.go | 4 ++-- tfexec/init.go | 2 +- tfexec/init_test.go | 6 ++++-- tfexec/output.go | 2 +- tfexec/output_test.go | 4 ++-- tfexec/plan.go | 2 +- tfexec/plan_test.go | 4 ++-- tfexec/providers_lock_test.go | 2 ++ tfexec/providers_schema.go | 2 +- tfexec/refresh.go | 2 +- tfexec/refresh_test.go | 4 ++-- tfexec/show.go | 1 - tfexec/show_test.go | 6 +++--- tfexec/state_mv.go | 2 +- tfexec/state_mv_test.go | 4 ++-- tfexec/state_rm.go | 2 +- tfexec/state_rm_test.go | 4 ++-- tfexec/taint.go | 2 +- tfexec/taint_test.go | 4 ++-- tfexec/terraform.go | 11 +++++++++-- tfexec/terraform_test.go | 6 ++++-- tfexec/untaint.go | 2 +- tfexec/untaint_test.go | 4 ++-- tfexec/upgrade012.go | 2 +- tfexec/upgrade012_test.go | 4 ++-- tfexec/upgrade013.go | 2 +- tfexec/upgrade013_test.go | 4 ++-- tfexec/validate.go | 2 +- tfexec/workspace_delete.go | 2 +- tfexec/workspace_delete_test.go | 4 ++-- tfexec/workspace_list.go | 2 +- tfexec/workspace_new.go | 2 +- tfexec/workspace_new_test.go | 4 ++-- tfexec/workspace_select.go | 2 +- tfexec/workspace_show.go | 2 +- 45 files changed, 81 insertions(+), 61 deletions(-) diff --git a/tfexec/apply.go b/tfexec/apply.go index 40d9e69b..5b100f8b 100644 --- a/tfexec/apply.go +++ b/tfexec/apply.go @@ -106,7 +106,7 @@ func (tf *Terraform) applyCmd(ctx context.Context, opts ...ApplyOption) (*exec.C o.configureApply(&c) } - args := []string{"apply", "-no-color", "-auto-approve", "-input=false"} + args := []string{"apply", "-auto-approve", "-input=false"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/apply_test.go b/tfexec/apply_test.go index 1cf2f562..a790359c 100644 --- a/tfexec/apply_test.go +++ b/tfexec/apply_test.go @@ -43,7 +43,6 @@ func TestApplyCmd(t *testing.T) { assertCmd(t, []string{ "apply", - "-no-color", "-auto-approve", "-input=false", "-backup=testbackup", @@ -62,6 +61,7 @@ func TestApplyCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "testfile", + "-no-color", }, nil, applyCmd) }) } diff --git a/tfexec/cmd.go b/tfexec/cmd.go index 56393a00..11a56510 100644 --- a/tfexec/cmd.go +++ b/tfexec/cmd.go @@ -180,7 +180,11 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string { } func (tf *Terraform) buildTerraformCmd(ctx context.Context, mergeEnv map[string]string, args ...string) *exec.Cmd { - cmd := exec.CommandContext(ctx, tf.execPath, args...) + if !tf.colors { + args = append(args, "-no-color") + } + + cmd := exec.Command(tf.execPath, args...) cmd.Env = tf.buildEnv(mergeEnv) cmd.Dir = tf.workingDir diff --git a/tfexec/destroy.go b/tfexec/destroy.go index 8011c0ba..e197a16e 100644 --- a/tfexec/destroy.go +++ b/tfexec/destroy.go @@ -102,7 +102,7 @@ func (tf *Terraform) destroyCmd(ctx context.Context, opts ...DestroyOption) (*ex o.configureDestroy(&c) } - args := []string{"destroy", "-no-color", "-auto-approve", "-input=false"} + args := []string{"destroy", "-auto-approve", "-input=false"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/destroy_test.go b/tfexec/destroy_test.go index eb28f58a..8d1b91ce 100644 --- a/tfexec/destroy_test.go +++ b/tfexec/destroy_test.go @@ -26,13 +26,13 @@ func TestDestroyCmd(t *testing.T) { assertCmd(t, []string{ "destroy", - "-no-color", "-auto-approve", "-input=false", "-lock-timeout=0s", "-lock=true", "-parallelism=10", "-refresh=true", + "-no-color", }, nil, destroyCmd) }) @@ -44,7 +44,6 @@ func TestDestroyCmd(t *testing.T) { assertCmd(t, []string{ "destroy", - "-no-color", "-auto-approve", "-input=false", "-backup=testbackup", @@ -60,6 +59,7 @@ func TestDestroyCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "destroydir", + "-no-color", }, nil, destroyCmd) }) } diff --git a/tfexec/fmt.go b/tfexec/fmt.go index 2234c79f..7b243e6d 100644 --- a/tfexec/fmt.go +++ b/tfexec/fmt.go @@ -145,7 +145,7 @@ func (tf *Terraform) formatCmd(ctx context.Context, args []string, opts ...Forma o.configureFormat(&c) } - args = append([]string{"fmt", "-no-color"}, args...) + args = append([]string{"fmt"}, args...) if c.recursive { args = append(args, "-recursive") diff --git a/tfexec/get.go b/tfexec/get.go index 5bac9b19..8427501c 100644 --- a/tfexec/get.go +++ b/tfexec/get.go @@ -40,7 +40,7 @@ func (tf *Terraform) getCmd(ctx context.Context, opts ...GetCmdOption) (*exec.Cm o.configureGet(&c) } - args := []string{"get", "-no-color"} + args := []string{"get"} args = append(args, "-update="+fmt.Sprint(c.update)) diff --git a/tfexec/get_test.go b/tfexec/get_test.go index 32cfbe0c..1fde9804 100644 --- a/tfexec/get_test.go +++ b/tfexec/get_test.go @@ -26,8 +26,8 @@ func TestGetCmd(t *testing.T) { assertCmd(t, []string{ "get", - "-no-color", "-update=false", + "-no-color", }, nil, getCmd) }) } diff --git a/tfexec/graph_test.go b/tfexec/graph_test.go index 628fe2d4..3782faad 100644 --- a/tfexec/graph_test.go +++ b/tfexec/graph_test.go @@ -28,6 +28,7 @@ func TestGraphCmd_v013(t *testing.T) { assertCmd(t, []string{ "graph", + "-no-color", }, nil, graphCmd) }) @@ -42,6 +43,7 @@ func TestGraphCmd_v013(t *testing.T) { "teststate", "-draw-cycles", "-type=output", + "-no-color", }, nil, graphCmd) }) } @@ -62,6 +64,7 @@ func TestGraphCmd_v1(t *testing.T) { assertCmd(t, []string{ "graph", + "-no-color", }, nil, graphCmd) }) @@ -76,6 +79,7 @@ func TestGraphCmd_v1(t *testing.T) { "-plan=teststate", "-draw-cycles", "-type=output", + "-no-color", }, nil, graphCmd) }) } diff --git a/tfexec/import.go b/tfexec/import.go index e243d728..456e6217 100644 --- a/tfexec/import.go +++ b/tfexec/import.go @@ -88,7 +88,7 @@ func (tf *Terraform) importCmd(ctx context.Context, address, id string, opts ... o.configureImport(&c) } - args := []string{"import", "-no-color", "-input=false"} + args := []string{"import", "-input=false"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/import_test.go b/tfexec/import_test.go index e1d5d6d7..8a88551c 100644 --- a/tfexec/import_test.go +++ b/tfexec/import_test.go @@ -26,12 +26,12 @@ func TestImportCmd(t *testing.T) { assertCmd(t, []string{ "import", - "-no-color", "-input=false", "-lock-timeout=0s", "-lock=true", "my-addr", "my-id", + "-no-color", }, nil, importCmd) }) @@ -53,7 +53,6 @@ func TestImportCmd(t *testing.T) { assertCmd(t, []string{ "import", - "-no-color", "-input=false", "-backup=testbackup", "-lock-timeout=200s", @@ -66,6 +65,7 @@ func TestImportCmd(t *testing.T) { "-var", "var2=bar", "my-addr2", "my-id2", + "-no-color", }, nil, importCmd) }) } diff --git a/tfexec/init.go b/tfexec/init.go index 8fd36677..dc9b26b6 100644 --- a/tfexec/init.go +++ b/tfexec/init.go @@ -120,7 +120,7 @@ func (tf *Terraform) initCmd(ctx context.Context, opts ...InitOption) (*exec.Cmd o.configureInit(&c) } - args := []string{"init", "-no-color", "-input=false"} + args := []string{"init", "-force-copy", "-input=false"} // string opts: only pass if set if c.fromModule != "" { diff --git a/tfexec/init_test.go b/tfexec/init_test.go index 4d1a7fd1..2f36e67a 100644 --- a/tfexec/init_test.go +++ b/tfexec/init_test.go @@ -32,7 +32,7 @@ func TestInitCmd_v012(t *testing.T) { assertCmd(t, []string{ "init", - "-no-color", + "-force-copy", "-input=false", "-lock-timeout=0s", "-backend=true", @@ -41,6 +41,7 @@ func TestInitCmd_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", + "-no-color", }, nil, initCmd) }) @@ -52,7 +53,7 @@ func TestInitCmd_v012(t *testing.T) { assertCmd(t, []string{ "init", - "-no-color", + "-force-copy", "-input=false", "-from-module=testsource", "-lock-timeout=999s", @@ -69,6 +70,7 @@ func TestInitCmd_v012(t *testing.T) { "-plugin-dir=testdir1", "-plugin-dir=testdir2", "initdir", + "-no-color", }, nil, initCmd) }) } diff --git a/tfexec/output.go b/tfexec/output.go index b16b8b72..02bb98d0 100644 --- a/tfexec/output.go +++ b/tfexec/output.go @@ -52,7 +52,7 @@ func (tf *Terraform) outputCmd(ctx context.Context, opts ...OutputOption) *exec. o.configureOutput(&c) } - args := []string{"output", "-no-color", "-json"} + args := []string{"output", "-json"} // string opts: only pass if set if c.state != "" { diff --git a/tfexec/output_test.go b/tfexec/output_test.go index 1df7a58c..6733e602 100644 --- a/tfexec/output_test.go +++ b/tfexec/output_test.go @@ -23,8 +23,8 @@ func TestOutputCmd(t *testing.T) { assertCmd(t, []string{ "output", - "-no-color", "-json", + "-no-color", }, nil, outputCmd) }) @@ -34,9 +34,9 @@ func TestOutputCmd(t *testing.T) { assertCmd(t, []string{ "output", - "-no-color", "-json", "-state=teststate", + "-no-color", }, nil, outputCmd) }) } diff --git a/tfexec/plan.go b/tfexec/plan.go index bf41094b..83791c04 100644 --- a/tfexec/plan.go +++ b/tfexec/plan.go @@ -115,7 +115,7 @@ func (tf *Terraform) planCmd(ctx context.Context, opts ...PlanOption) (*exec.Cmd o.configurePlan(&c) } - args := []string{"plan", "-no-color", "-input=false", "-detailed-exitcode"} + args := []string{"plan", "-input=false", "-detailed-exitcode"} // string opts: only pass if set if c.lockTimeout != "" { diff --git a/tfexec/plan_test.go b/tfexec/plan_test.go index 7a467ac3..eda22393 100644 --- a/tfexec/plan_test.go +++ b/tfexec/plan_test.go @@ -26,13 +26,13 @@ func TestPlanCmd(t *testing.T) { assertCmd(t, []string{ "plan", - "-no-color", "-input=false", "-detailed-exitcode", "-lock-timeout=0s", "-lock=true", "-parallelism=10", "-refresh=true", + "-no-color", }, nil, planCmd) }) @@ -59,7 +59,6 @@ func TestPlanCmd(t *testing.T) { assertCmd(t, []string{ "plan", - "-no-color", "-input=false", "-detailed-exitcode", "-lock-timeout=22s", @@ -77,6 +76,7 @@ func TestPlanCmd(t *testing.T) { "-var", "android=paranoid", "-var", "brain_size=planet", "earth", + "-no-color", }, nil, planCmd) }) } diff --git a/tfexec/providers_lock_test.go b/tfexec/providers_lock_test.go index 82e1d8e7..c46fc124 100644 --- a/tfexec/providers_lock_test.go +++ b/tfexec/providers_lock_test.go @@ -24,6 +24,7 @@ func TestProvidersLockCmd(t *testing.T) { assertCmd(t, []string{ "providers", "lock", + "-no-color", }, nil, lockCmd) }) @@ -37,6 +38,7 @@ func TestProvidersLockCmd(t *testing.T) { "-net-mirror=test", "-platform=linux_amd64", "workingdir", + "-no-color", }, nil, lockCmd) }) } diff --git a/tfexec/providers_schema.go b/tfexec/providers_schema.go index 52efc5db..22e2ed08 100644 --- a/tfexec/providers_schema.go +++ b/tfexec/providers_schema.go @@ -26,7 +26,7 @@ func (tf *Terraform) ProvidersSchema(ctx context.Context) (*tfjson.ProviderSchem } func (tf *Terraform) providersSchemaCmd(ctx context.Context, args ...string) *exec.Cmd { - allArgs := []string{"providers", "schema", "-json", "-no-color"} + allArgs := []string{"providers", "schema", "-json"} allArgs = append(allArgs, args...) return tf.buildTerraformCmd(ctx, nil, allArgs...) diff --git a/tfexec/refresh.go b/tfexec/refresh.go index 78f6b4b5..4b8f1bcf 100644 --- a/tfexec/refresh.go +++ b/tfexec/refresh.go @@ -85,7 +85,7 @@ func (tf *Terraform) refreshCmd(ctx context.Context, opts ...RefreshCmdOption) ( o.configureRefresh(&c) } - args := []string{"refresh", "-no-color", "-input=false"} + args := []string{"refresh", "-input=false"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/refresh_test.go b/tfexec/refresh_test.go index bd4a94c4..b2179146 100644 --- a/tfexec/refresh_test.go +++ b/tfexec/refresh_test.go @@ -26,10 +26,10 @@ func TestRefreshCmd(t *testing.T) { assertCmd(t, []string{ "refresh", - "-no-color", "-input=false", "-lock-timeout=0s", "-lock=true", + "-no-color", }, nil, refreshCmd) }) @@ -41,7 +41,6 @@ func TestRefreshCmd(t *testing.T) { assertCmd(t, []string{ "refresh", - "-no-color", "-input=false", "-backup=testbackup", "-lock-timeout=200s", @@ -54,6 +53,7 @@ func TestRefreshCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "refreshdir", + "-no-color", }, nil, refreshCmd) }) } diff --git a/tfexec/show.go b/tfexec/show.go index 61e660ac..69bfd310 100644 --- a/tfexec/show.go +++ b/tfexec/show.go @@ -189,7 +189,6 @@ func (tf *Terraform) showCmd(ctx context.Context, jsonOutput bool, mergeEnv map[ if jsonOutput { allArgs = append(allArgs, "-json") } - allArgs = append(allArgs, "-no-color") allArgs = append(allArgs, args...) return tf.buildTerraformCmd(ctx, mergeEnv, allArgs...) diff --git a/tfexec/show_test.go b/tfexec/show_test.go index 0cace759..37f5635f 100644 --- a/tfexec/show_test.go +++ b/tfexec/show_test.go @@ -44,8 +44,8 @@ func TestShowStateFileCmd(t *testing.T) { assertCmd(t, []string{ "show", "-json", - "-no-color", "statefilepath", + "-no-color", }, nil, showCmd) } @@ -65,8 +65,8 @@ func TestShowPlanFileCmd(t *testing.T) { assertCmd(t, []string{ "show", "-json", - "-no-color", "planfilepath", + "-no-color", }, nil, showCmd) } @@ -85,7 +85,7 @@ func TestShowPlanFileRawCmd(t *testing.T) { assertCmd(t, []string{ "show", - "-no-color", "planfilepath", + "-no-color", }, nil, showCmd) } diff --git a/tfexec/state_mv.go b/tfexec/state_mv.go index fc7eecf8..548207c7 100644 --- a/tfexec/state_mv.go +++ b/tfexec/state_mv.go @@ -70,7 +70,7 @@ func (tf *Terraform) stateMvCmd(ctx context.Context, source string, destination o.configureStateMv(&c) } - args := []string{"state", "mv", "-no-color"} + args := []string{"state", "mv"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/state_mv_test.go b/tfexec/state_mv_test.go index 47597693..08a58ddb 100644 --- a/tfexec/state_mv_test.go +++ b/tfexec/state_mv_test.go @@ -27,11 +27,11 @@ func TestStateMvCmd(t *testing.T) { assertCmd(t, []string{ "state", "mv", - "-no-color", "-lock-timeout=0s", "-lock=true", "testsource", "testdestination", + "-no-color", }, nil, stateMvCmd) }) @@ -44,7 +44,6 @@ func TestStateMvCmd(t *testing.T) { assertCmd(t, []string{ "state", "mv", - "-no-color", "-backup=testbackup", "-backup-out=testbackupout", "-lock-timeout=200s", @@ -53,6 +52,7 @@ func TestStateMvCmd(t *testing.T) { "-lock=false", "testsrc", "testdest", + "-no-color", }, nil, stateMvCmd) }) } diff --git a/tfexec/state_rm.go b/tfexec/state_rm.go index 0c5dd666..7f47a203 100644 --- a/tfexec/state_rm.go +++ b/tfexec/state_rm.go @@ -70,7 +70,7 @@ func (tf *Terraform) stateRmCmd(ctx context.Context, address string, opts ...Sta o.configureStateRm(&c) } - args := []string{"state", "rm", "-no-color"} + args := []string{"state", "rm"} // string opts: only pass if set if c.backup != "" { diff --git a/tfexec/state_rm_test.go b/tfexec/state_rm_test.go index 0a7843bd..f61b301e 100644 --- a/tfexec/state_rm_test.go +++ b/tfexec/state_rm_test.go @@ -27,10 +27,10 @@ func TestStateRmCmd(t *testing.T) { assertCmd(t, []string{ "state", "rm", - "-no-color", "-lock-timeout=0s", "-lock=true", "testAddress", + "-no-color", }, nil, stateRmCmd) }) @@ -43,7 +43,6 @@ func TestStateRmCmd(t *testing.T) { assertCmd(t, []string{ "state", "rm", - "-no-color", "-backup=testbackup", "-backup-out=testbackupout", "-lock-timeout=200s", @@ -51,6 +50,7 @@ func TestStateRmCmd(t *testing.T) { "-state-out=teststateout", "-lock=false", "testAddress", + "-no-color", }, nil, stateRmCmd) }) } diff --git a/tfexec/taint.go b/tfexec/taint.go index cd69df30..8fefae77 100644 --- a/tfexec/taint.go +++ b/tfexec/taint.go @@ -57,7 +57,7 @@ func (tf *Terraform) taintCmd(ctx context.Context, address string, opts ...Taint o.configureTaint(&c) } - args := []string{"taint", "-no-color"} + args := []string{"taint"} if c.lockTimeout != "" { args = append(args, "-lock-timeout="+c.lockTimeout) diff --git a/tfexec/taint_test.go b/tfexec/taint_test.go index ed0ec695..49a22e45 100644 --- a/tfexec/taint_test.go +++ b/tfexec/taint_test.go @@ -23,9 +23,9 @@ func TestTaintCmd(t *testing.T) { assertCmd(t, []string{ "taint", - "-no-color", "-lock=true", "aws_instance.foo", + "-no-color", }, nil, taintCmd) }) @@ -38,12 +38,12 @@ func TestTaintCmd(t *testing.T) { assertCmd(t, []string{ "taint", - "-no-color", "-lock-timeout=200s", "-state=teststate", "-lock=false", "-allow-missing", "aws_instance.foo", + "-no-color", }, nil, taintCmd) }) } diff --git a/tfexec/terraform.go b/tfexec/terraform.go index 10d7d9ad..283ba491 100644 --- a/tfexec/terraform.go +++ b/tfexec/terraform.go @@ -3,13 +3,12 @@ package tfexec import ( "context" "fmt" + "github.com/hashicorp/go-version" "io" "io/ioutil" "log" "os" "sync" - - "github.com/hashicorp/go-version" ) type printfer interface { @@ -47,6 +46,7 @@ type Terraform struct { disablePluginTLS bool skipProviderVerify bool env map[string]string + colors bool stdout io.Writer stderr io.Writer @@ -92,6 +92,7 @@ func NewTerraform(workingDir string, execPath string) (*Terraform, error) { workingDir: workingDir, env: nil, // explicit nil means copy os.Environ logger: log.New(ioutil.Discard, "", 0), + colors: false, } return &tf, nil @@ -213,6 +214,12 @@ func (tf *Terraform) SetSkipProviderVerify(skip bool) error { return nil } +// SetColor enables ansi colors for +// Terraform CLI execution. +func (tf *Terraform) SetColor(c bool) { + tf.colors = c +} + // WorkingDir returns the working directory for Terraform. func (tf *Terraform) WorkingDir() string { return tf.workingDir diff --git a/tfexec/terraform_test.go b/tfexec/terraform_test.go index 79338ea8..7caeeff9 100644 --- a/tfexec/terraform_test.go +++ b/tfexec/terraform_test.go @@ -694,7 +694,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { assertCmd(t, []string{ "init", - "-no-color", + "-force-copy", "-input=false", "-lock-timeout=0s", "-backend=true", @@ -703,6 +703,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", + "-no-color", }, map[string]string{ "CHECKPOINT_DISABLE": "1", "FOOBAR": "1", @@ -725,7 +726,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { assertCmd(t, []string{ "init", - "-no-color", + "-force-copy", "-input=false", "-lock-timeout=0s", "-backend=true", @@ -734,6 +735,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", + "-no-color", }, map[string]string{ "CHECKPOINT_DISABLE": "", "FOOBAR": "2", diff --git a/tfexec/untaint.go b/tfexec/untaint.go index bda12727..55d6efcb 100644 --- a/tfexec/untaint.go +++ b/tfexec/untaint.go @@ -57,7 +57,7 @@ func (tf *Terraform) untaintCmd(ctx context.Context, address string, opts ...Unt o.configureUntaint(&c) } - args := []string{"untaint", "-no-color"} + args := []string{"untaint"} if c.lockTimeout != "" { args = append(args, "-lock-timeout="+c.lockTimeout) diff --git a/tfexec/untaint_test.go b/tfexec/untaint_test.go index cfe9085f..801cc07e 100644 --- a/tfexec/untaint_test.go +++ b/tfexec/untaint_test.go @@ -23,9 +23,9 @@ func TestUntaintCmd(t *testing.T) { assertCmd(t, []string{ "untaint", - "-no-color", "-lock=true", "aws_instance.foo", + "-no-color", }, nil, untaintCmd) }) @@ -38,12 +38,12 @@ func TestUntaintCmd(t *testing.T) { assertCmd(t, []string{ "untaint", - "-no-color", "-lock-timeout=200s", "-state=teststate", "-lock=false", "-allow-missing", "aws_instance.foo", + "-no-color", }, nil, untaintCmd) }) } diff --git a/tfexec/upgrade012.go b/tfexec/upgrade012.go index e55237a7..d86bb132 100644 --- a/tfexec/upgrade012.go +++ b/tfexec/upgrade012.go @@ -55,7 +55,7 @@ func (tf *Terraform) upgrade012Cmd(ctx context.Context, opts ...Upgrade012Option o.configureUpgrade012(&c) } - args := []string{"0.12upgrade", "-no-color", "-yes"} + args := []string{"0.12upgrade", "-yes"} // boolean opts: only pass if set if c.force { diff --git a/tfexec/upgrade012_test.go b/tfexec/upgrade012_test.go index 71fc606e..7b5fff4a 100644 --- a/tfexec/upgrade012_test.go +++ b/tfexec/upgrade012_test.go @@ -33,8 +33,8 @@ func TestUpgrade012(t *testing.T) { assertCmd(t, []string{ "0.12upgrade", - "-no-color", "-yes", + "-no-color", }, nil, upgrade012Cmd) }) @@ -54,10 +54,10 @@ func TestUpgrade012(t *testing.T) { assertCmd(t, []string{ "0.12upgrade", - "-no-color", "-yes", "-force", "upgrade012dir", + "-no-color", }, nil, upgrade012Cmd) }) diff --git a/tfexec/upgrade013.go b/tfexec/upgrade013.go index f1f444e2..392258e6 100644 --- a/tfexec/upgrade013.go +++ b/tfexec/upgrade013.go @@ -48,7 +48,7 @@ func (tf *Terraform) upgrade013Cmd(ctx context.Context, opts ...Upgrade013Option o.configureUpgrade013(&c) } - args := []string{"0.13upgrade", "-no-color", "-yes"} + args := []string{"0.13upgrade", "-yes"} // optional positional argument if c.dir != "" { diff --git a/tfexec/upgrade013_test.go b/tfexec/upgrade013_test.go index 5704f274..0f510cff 100644 --- a/tfexec/upgrade013_test.go +++ b/tfexec/upgrade013_test.go @@ -33,8 +33,8 @@ func TestUpgrade013(t *testing.T) { assertCmd(t, []string{ "0.13upgrade", - "-no-color", "-yes", + "-no-color", }, nil, upgrade013Cmd) }) @@ -54,9 +54,9 @@ func TestUpgrade013(t *testing.T) { assertCmd(t, []string{ "0.13upgrade", - "-no-color", "-yes", "upgrade013dir", + "-no-color", }, nil, upgrade013Cmd) }) diff --git a/tfexec/validate.go b/tfexec/validate.go index 320011df..33278a8f 100644 --- a/tfexec/validate.go +++ b/tfexec/validate.go @@ -17,7 +17,7 @@ func (tf *Terraform) Validate(ctx context.Context) (*tfjson.ValidateOutput, erro return nil, fmt.Errorf("terraform validate -json was added in 0.12.0: %w", err) } - cmd := tf.buildTerraformCmd(ctx, nil, "validate", "-no-color", "-json") + cmd := tf.buildTerraformCmd(ctx, nil, "validate", "-json") var outBuf = bytes.Buffer{} cmd.Stdout = &outBuf diff --git a/tfexec/workspace_delete.go b/tfexec/workspace_delete.go index 52677207..ba1374b3 100644 --- a/tfexec/workspace_delete.go +++ b/tfexec/workspace_delete.go @@ -59,7 +59,7 @@ func (tf *Terraform) workspaceDeleteCmd(ctx context.Context, workspace string, o o.configureWorkspaceDelete(&c) } - args := []string{"workspace", "delete", "-no-color"} + args := []string{"workspace", "delete"} if c.force { args = append(args, "-force") diff --git a/tfexec/workspace_delete_test.go b/tfexec/workspace_delete_test.go index 60c363eb..4aaf6790 100644 --- a/tfexec/workspace_delete_test.go +++ b/tfexec/workspace_delete_test.go @@ -24,8 +24,8 @@ func TestWorkspaceDeleteCmd(t *testing.T) { assertCmd(t, []string{ "workspace", "delete", - "-no-color", "workspace-name", + "-no-color", }, nil, workspaceDeleteCmd) }) @@ -40,11 +40,11 @@ func TestWorkspaceDeleteCmd(t *testing.T) { assertCmd(t, []string{ "workspace", "delete", - "-no-color", "-force", "-lock-timeout=200s", "-lock=false", "workspace-name", + "-no-color", }, nil, workspaceDeleteCmd) }) } diff --git a/tfexec/workspace_list.go b/tfexec/workspace_list.go index 33c0d779..39caa456 100644 --- a/tfexec/workspace_list.go +++ b/tfexec/workspace_list.go @@ -8,7 +8,7 @@ import ( // WorkspaceList represents the workspace list subcommand to the Terraform CLI. func (tf *Terraform) WorkspaceList(ctx context.Context) ([]string, string, error) { // TODO: [DIR] param option - wlCmd := tf.buildTerraformCmd(ctx, nil, "workspace", "list", "-no-color") + wlCmd := tf.buildTerraformCmd(ctx, nil, "workspace", "list") var outBuf strings.Builder wlCmd.Stdout = &outBuf diff --git a/tfexec/workspace_new.go b/tfexec/workspace_new.go index 2e05ffdb..a01f81a6 100644 --- a/tfexec/workspace_new.go +++ b/tfexec/workspace_new.go @@ -61,7 +61,7 @@ func (tf *Terraform) workspaceNewCmd(ctx context.Context, workspace string, opts o.configureWorkspaceNew(&c) } - args := []string{"workspace", "new", "-no-color"} + args := []string{"workspace", "new"} if c.lockTimeout != "" && c.lockTimeout != defaultWorkspaceNewOptions.lockTimeout { // only pass if not default, so we don't need to worry about the 0.11 version check diff --git a/tfexec/workspace_new_test.go b/tfexec/workspace_new_test.go index 63471376..e20b7873 100644 --- a/tfexec/workspace_new_test.go +++ b/tfexec/workspace_new_test.go @@ -33,8 +33,8 @@ func TestWorkspaceNewCmd(t *testing.T) { assertCmd(t, []string{ "workspace", "new", - "-no-color", "workspace-name", + "-no-color", }, nil, workspaceNewCmd) }) @@ -46,11 +46,11 @@ func TestWorkspaceNewCmd(t *testing.T) { assertCmd(t, []string{ "workspace", "new", - "-no-color", "-lock-timeout=200s", "-lock=false", "-state=teststate", "workspace-name", + "-no-color", }, nil, workspaceNewCmd) }) } diff --git a/tfexec/workspace_select.go b/tfexec/workspace_select.go index 5a51330f..b0f1bcef 100644 --- a/tfexec/workspace_select.go +++ b/tfexec/workspace_select.go @@ -6,5 +6,5 @@ import "context" func (tf *Terraform) WorkspaceSelect(ctx context.Context, workspace string) error { // TODO: [DIR] param option - return tf.runTerraformCmd(ctx, tf.buildTerraformCmd(ctx, nil, "workspace", "select", "-no-color", workspace)) + return tf.runTerraformCmd(ctx, tf.buildTerraformCmd(ctx, nil, "workspace", "select", workspace)) } diff --git a/tfexec/workspace_show.go b/tfexec/workspace_show.go index 7d5a267f..2a3792db 100644 --- a/tfexec/workspace_show.go +++ b/tfexec/workspace_show.go @@ -31,5 +31,5 @@ func (tf *Terraform) workspaceShowCmd(ctx context.Context) (*exec.Cmd, error) { return nil, fmt.Errorf("workspace show was first introduced in Terraform 0.10.0: %w", err) } - return tf.buildTerraformCmd(ctx, nil, "workspace", "show", "-no-color"), nil + return tf.buildTerraformCmd(ctx, nil, "workspace", "show"), nil } From 3d5d15e21122e9272c77fbb51a00932b0dd7dba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6nthal?= Date: Tue, 22 Feb 2022 23:45:55 +0100 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 170 ++++++++++++++++---------------- tfexec/apply_test.go | 2 +- tfexec/cmd.go | 34 ++++++- tfexec/destroy_test.go | 4 +- tfexec/get_test.go | 2 +- tfexec/graph_test.go | 4 +- tfexec/import_test.go | 4 +- tfexec/init_test.go | 4 +- tfexec/output_test.go | 4 +- tfexec/plan_test.go | 4 +- tfexec/providers_lock_test.go | 2 +- tfexec/providers_schema_test.go | 2 +- tfexec/refresh_test.go | 4 +- tfexec/show_test.go | 6 +- tfexec/state_mv_test.go | 4 +- tfexec/state_pull_test.go | 1 + tfexec/state_push_test.go | 2 + tfexec/state_rm_test.go | 4 +- tfexec/taint_test.go | 4 +- tfexec/terraform_test.go | 4 +- tfexec/untaint_test.go | 4 +- tfexec/upgrade012_test.go | 4 +- tfexec/upgrade013_test.go | 4 +- tfexec/workspace_delete_test.go | 8 +- tfexec/workspace_new_test.go | 8 +- 25 files changed, 165 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 586a4707..cd48fb5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,40 +4,40 @@ Please note that terraform-exec now requires Go 1.18. BUG FIXES: - - Fix bug in which `terraform init` was always called with the `-force-copy` flag ([#268](https://github.com/hashicorp/terraform-exec/issues/268)) - - Always pass `-no-color` flag when calling `terraform force-unlock` ([#270](https://github.com/hashicorp/terraform-exec/issues/270)) +- Fix bug in which `terraform init` was always called with the `-force-copy` flag ([#268](https://github.com/hashicorp/terraform-exec/issues/268)) +- Always pass `-no-color` flag when calling `terraform force-unlock` ([#270](https://github.com/hashicorp/terraform-exec/issues/270)) # 0.17.2 (July 01, 2022) ENHANCEMENTS: - - tfexec: Add `(Terraform).SetLogCore()` and `(Terraform).SetLogProvider()` methods ([#324](https://github.com/hashicorp/terraform-exec/pull/324)) +- tfexec: Add `(Terraform).SetLogCore()` and `(Terraform).SetLogProvider()` methods ([#324](https://github.com/hashicorp/terraform-exec/pull/324)) INTERNAL: - - Bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0 ([#323](https://github.com/hashicorp/terraform-exec/pull/323)) +- Bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0 ([#323](https://github.com/hashicorp/terraform-exec/pull/323)) # 0.17.1 (June 27, 2022) BUG FIXES: - - Fix bug in which `StatePush` would fail with "Exactly one argument expected" ([#316](https://github.com/hashicorp/terraform-exec/issues/316)) +- Fix bug in which `StatePush` would fail with "Exactly one argument expected" ([#316](https://github.com/hashicorp/terraform-exec/issues/316)) # 0.17.0 (June 22, 2022) FEATURES: - - Add `SetLog()` method for `Terraform` ([#291](https://github.com/hashicorp/terraform-exec/pull/291)) - - Add support for `state pull` and `state push` ([#215](https://github.com/hashicorp/terraform-exec/pull/215)) - - Add support for running e2e tests against a local Terraform executable with `TFEXEC_E2ETEST_TERRAFORM_PATH` ([#305](https://github.com/hashicorp/terraform-exec/pull/305)) +- Add `SetLog()` method for `Terraform` ([#291](https://github.com/hashicorp/terraform-exec/pull/291)) +- Add support for `state pull` and `state push` ([#215](https://github.com/hashicorp/terraform-exec/pull/215)) +- Add support for running e2e tests against a local Terraform executable with `TFEXEC_E2ETEST_TERRAFORM_PATH` ([#305](https://github.com/hashicorp/terraform-exec/pull/305)) BUG FIXES: - - Avoid data race conditions ([#299](https://github.com/hashicorp/terraform-exec/pull/299)) +- Avoid data race conditions ([#299](https://github.com/hashicorp/terraform-exec/pull/299)) INTERNAL: - - Bump github.com/hashicorp/go-version from 1.4.0 to 1.5.0 ([#306](https://github.com/hashicorp/terraform-exec/pull/306)) +- Bump github.com/hashicorp/go-version from 1.4.0 to 1.5.0 ([#306](https://github.com/hashicorp/terraform-exec/pull/306)) # 0.16.1 (April 13, 2022) @@ -51,200 +51,200 @@ Please note also terraform-exec's Go version support policy, which, like Go's ow BREAKING CHANGES: - - Remove `tfinstall` and `cmd/tfinstall` packages ([#235](https://github.com/hashicorp/terraform-exec/issues/235)) - - Remove support for `add` command ([#232](https://github.com/hashicorp/terraform-exec/issues/232)) +- Remove `tfinstall` and `cmd/tfinstall` packages ([#235](https://github.com/hashicorp/terraform-exec/issues/235)) +- Remove support for `add` command ([#232](https://github.com/hashicorp/terraform-exec/issues/232)) FEATURES: - - Add support for `workspace delete` command ([#212](https://github.com/hashicorp/terraform-exec/issues/212)) - - Add support for `workspace show` command ([#245](https://github.com/hashicorp/terraform-exec/issues/245)) - - Add support for `force-unlock` command ([#223](https://github.com/hashicorp/terraform-exec/issues/223)) - - Add support for `graph` command ([#257](https://github.com/hashicorp/terraform-exec/issues/257)) - - Add support for `taint` command ([#251](https://github.com/hashicorp/terraform-exec/issues/251)) - - Add support for `untaint` command ([#251](https://github.com/hashicorp/terraform-exec/issues/251)) - - Add `ErrStatePlanRead`, returned when Terraform cannot read a given state or plan file ([#273](https://github.com/hashicorp/terraform-exec/issues/273)) +- Add support for `workspace delete` command ([#212](https://github.com/hashicorp/terraform-exec/issues/212)) +- Add support for `workspace show` command ([#245](https://github.com/hashicorp/terraform-exec/issues/245)) +- Add support for `force-unlock` command ([#223](https://github.com/hashicorp/terraform-exec/issues/223)) +- Add support for `graph` command ([#257](https://github.com/hashicorp/terraform-exec/issues/257)) +- Add support for `taint` command ([#251](https://github.com/hashicorp/terraform-exec/issues/251)) +- Add support for `untaint` command ([#251](https://github.com/hashicorp/terraform-exec/issues/251)) +- Add `ErrStatePlanRead`, returned when Terraform cannot read a given state or plan file ([#273](https://github.com/hashicorp/terraform-exec/issues/273)) # 0.15.0 (October 05, 2021) FEATURES: - - Add support for `providers lock` command ([#203](https://github.com/hashicorp/terraform-exec/issues/203)) - - Add support for `add` command ([#209](https://github.com/hashicorp/terraform-exec/issues/209)) - - Add support for `Plan`/`Apply` `Replace` option ([#211](https://github.com/hashicorp/terraform-exec/issues/211)) +- Add support for `providers lock` command ([#203](https://github.com/hashicorp/terraform-exec/issues/203)) +- Add support for `add` command ([#209](https://github.com/hashicorp/terraform-exec/issues/209)) +- Add support for `Plan`/`Apply` `Replace` option ([#211](https://github.com/hashicorp/terraform-exec/issues/211)) ENHANCEMENTS: - - Introduce `tfexec.ErrStateLocked` to represent locked state error ([#221](https://github.com/hashicorp/terraform-exec/issues/221)) - - Account for upcoming init error message change ([#228](https://github.com/hashicorp/terraform-exec/issues/228)) +- Introduce `tfexec.ErrStateLocked` to represent locked state error ([#221](https://github.com/hashicorp/terraform-exec/issues/221)) +- Account for upcoming init error message change ([#228](https://github.com/hashicorp/terraform-exec/issues/228)) INTERNAL: - - deps: Bump terraform-json to `0.13.0` to address panic & support v1 JSON format ([#224](https://github.com/hashicorp/terraform-exec/issues/224)) +- deps: Bump terraform-json to `0.13.0` to address panic & support v1 JSON format ([#224](https://github.com/hashicorp/terraform-exec/issues/224)) # 0.14.0 (June 24, 2021) FEATURES: - - Add `ProtocolVersion` to `ReattachConfig` struct, enabling provider protocol v6 support in reattach mode, provided that Terraform and the provider plugin are both using go-plugin v1.4.1 or later. This change is backwards-compatible, as zero values for this field are interpreted as protocol v5. ([#182](https://github.com/hashicorp/terraform-exec/issues/182)) - - Introduce `tfexec.Get()` for downloading modules ([#176](https://github.com/hashicorp/terraform-exec/issues/176)) - - Introduce `tfexec.Upgrade013()` ([#178](https://github.com/hashicorp/terraform-exec/issues/178)) +- Add `ProtocolVersion` to `ReattachConfig` struct, enabling provider protocol v6 support in reattach mode, provided that Terraform and the provider plugin are both using go-plugin v1.4.1 or later. This change is backwards-compatible, as zero values for this field are interpreted as protocol v5. ([#182](https://github.com/hashicorp/terraform-exec/issues/182)) +- Introduce `tfexec.Get()` for downloading modules ([#176](https://github.com/hashicorp/terraform-exec/issues/176)) +- Introduce `tfexec.Upgrade013()` ([#178](https://github.com/hashicorp/terraform-exec/issues/178)) INTERNAL: - - Update `terraform-json` to account for changes in state & plan JSON output in Terraform v1.0.1+ ([#194](https://github.com/hashicorp/terraform-exec/issues/194)) - - Improve error message for incompatible Terraform version ([#191](https://github.com/hashicorp/terraform-exec/issues/191)) +- Update `terraform-json` to account for changes in state & plan JSON output in Terraform v1.0.1+ ([#194](https://github.com/hashicorp/terraform-exec/issues/194)) +- Improve error message for incompatible Terraform version ([#191](https://github.com/hashicorp/terraform-exec/issues/191)) # 0.13.3 (April 23, 2021) SECURITY: - - `tfinstall`: The HashiCorp PGP signing key has been rotated ([HCSEC-2021-12](https://discuss.hashicorp.com/t/hcsec-2021-12-codecov-security-event-and-hashicorp-gpg-key-exposure/23512)). This key is used to verify downloaded versions of Terraform. We recommend all users of terraform-exec upgrade to v0.13.3 for this security fix. ([#166](https://github.com/hashicorp/terraform-exec/issues/166)) +- `tfinstall`: The HashiCorp PGP signing key has been rotated ([HCSEC-2021-12](https://discuss.hashicorp.com/t/hcsec-2021-12-codecov-security-event-and-hashicorp-gpg-key-exposure/23512)). This key is used to verify downloaded versions of Terraform. We recommend all users of terraform-exec upgrade to v0.13.3 for this security fix. ([#166](https://github.com/hashicorp/terraform-exec/issues/166)) N.B. Versions of terraform-exec prior to v0.13.3 will continue to verify older versions of Terraform (up to and including v0.15.0) for a limited period. **Installation of Terraform using older versions of terraform-exec will stop working soon, and we recommend upgrading as soon as possible to avoid any interruption.** # 0.13.2 (April 06, 2021) BUG FIXES: - - Update `terraform-json` to support 0.15 changes in plan & config JSON output ([#153](https://github.com/hashicorp/terraform-exec/issues/153)) - - Update `go-getter` to prevent race conditions where consumers would require `go-cleanhttp` `>=0.5.2` (which tfexec itself didn't depend on until now) ([#154](https://github.com/hashicorp/terraform-exec/issues/154)) +- Update `terraform-json` to support 0.15 changes in plan & config JSON output ([#153](https://github.com/hashicorp/terraform-exec/issues/153)) +- Update `go-getter` to prevent race conditions where consumers would require `go-cleanhttp` `>=0.5.2` (which tfexec itself didn't depend on until now) ([#154](https://github.com/hashicorp/terraform-exec/issues/154)) # 0.13.1 (March 29, 2021) BUG FIXES: - - Bump version of terraform-json library to handle latest Terraform 0.15 output format ([#143](https://github.com/hashicorp/terraform-exec/issues/143)) +- Bump version of terraform-json library to handle latest Terraform 0.15 output format ([#143](https://github.com/hashicorp/terraform-exec/issues/143)) NOTES: - - This release no longer supports Go 1.12 (1.13+ is required) +- This release no longer supports Go 1.12 (1.13+ is required) # 0.13.0 (February 05, 2021) Please note that this is the first release of terraform-exec compatible with Terraform 0.15. Running Terraform 0.15 commands with previous versions of terraform-exec may produce unexpected results. FEATURES: - - Compatibility checks for CLI flags removed in Terraform 0.15 ([#120](https://github.com/hashicorp/terraform-exec/issues/120)) - - Introduce `StateRm` method ([#122](https://github.com/hashicorp/terraform-exec/issues/122)) +- Compatibility checks for CLI flags removed in Terraform 0.15 ([#120](https://github.com/hashicorp/terraform-exec/issues/120)) +- Introduce `StateRm` method ([#122](https://github.com/hashicorp/terraform-exec/issues/122)) # 0.12.0 (December 18, 2020) BREAKING CHANGES: - - Move Git ref installation to subpackage so that consumers can limit dependencies ([#98](https://github.com/hashicorp/terraform-exec/issues/98)) +- Move Git ref installation to subpackage so that consumers can limit dependencies ([#98](https://github.com/hashicorp/terraform-exec/issues/98)) FEATURES: - - Improve error handling for formatting command on unsupported version (`<0.7.7`) ([#88](https://github.com/hashicorp/terraform-exec/issues/88)) - - Introduce `Format` method with `io.Reader`/`io.Writer` interfaces ([#96](https://github.com/hashicorp/terraform-exec/issues/96)) - - Introduce `Validate` method with `tfjson` defined diagnostic types. Those types reflect exactly the types used in `terraform validate -json` output ([#68](https://github.com/hashicorp/terraform-exec/issues/68)) - - Introduce `StateMv` method ([#112](https://github.com/hashicorp/terraform-exec/issues/112)) - - Introduce `Upgrade012` method ([#105](https://github.com/hashicorp/terraform-exec/issues/105)) +- Improve error handling for formatting command on unsupported version (`<0.7.7`) ([#88](https://github.com/hashicorp/terraform-exec/issues/88)) +- Introduce `Format` method with `io.Reader`/`io.Writer` interfaces ([#96](https://github.com/hashicorp/terraform-exec/issues/96)) +- Introduce `Validate` method with `tfjson` defined diagnostic types. Those types reflect exactly the types used in `terraform validate -json` output ([#68](https://github.com/hashicorp/terraform-exec/issues/68)) +- Introduce `StateMv` method ([#112](https://github.com/hashicorp/terraform-exec/issues/112)) +- Introduce `Upgrade012` method ([#105](https://github.com/hashicorp/terraform-exec/issues/105)) BUG FIXES: - - Fix issue in tfinstall.GitRef where it assumed a `vendor` directory was present ([#89](https://github.com/hashicorp/terraform-exec/issues/89)) - - Use `json.Number` instead of `float64` when parsing state ([#113](https://github.com/hashicorp/terraform-exec/issues/113)) - - Support long variable names in `ErrMissingVar` ([#110](https://github.com/hashicorp/terraform-exec/issues/110)) +- Fix issue in tfinstall.GitRef where it assumed a `vendor` directory was present ([#89](https://github.com/hashicorp/terraform-exec/issues/89)) +- Use `json.Number` instead of `float64` when parsing state ([#113](https://github.com/hashicorp/terraform-exec/issues/113)) +- Support long variable names in `ErrMissingVar` ([#110](https://github.com/hashicorp/terraform-exec/issues/110)) # 0.11.0 (September 23, 2020) FEATURES: - - Added Terraform fmt support with the ability to format and write files/folders, check if files/folders need formatting, and format strings directly ([#82](https://github.com/hashicorp/terraform-exec/issues/82)) - - Added support for refs in the tfinstall CLI ([#80](https://github.com/hashicorp/terraform-exec/issues/80)) +- Added Terraform fmt support with the ability to format and write files/folders, check if files/folders need formatting, and format strings directly ([#82](https://github.com/hashicorp/terraform-exec/issues/82)) +- Added support for refs in the tfinstall CLI ([#80](https://github.com/hashicorp/terraform-exec/issues/80)) N.B. tfinstall binaries for all supported platforms are now available via GitHub Releases. # 0.10.0 (September 15, 2020) FEATURES: - - Added the ability to customize the `User-Agent` header for some `tfinstall` finders ([#76](https://github.com/hashicorp/terraform-exec/issues/76)) - - Added well known error for a mismatch for `required_version` ([#66](https://github.com/hashicorp/terraform-exec/issues/66)) - - Added new `ShowPlanFileRaw` function to obtain the human-friendly output of a plan ([#83](https://github.com/hashicorp/terraform-exec/issues/83)) +- Added the ability to customize the `User-Agent` header for some `tfinstall` finders ([#76](https://github.com/hashicorp/terraform-exec/issues/76)) +- Added well known error for a mismatch for `required_version` ([#66](https://github.com/hashicorp/terraform-exec/issues/66)) +- Added new `ShowPlanFileRaw` function to obtain the human-friendly output of a plan ([#83](https://github.com/hashicorp/terraform-exec/issues/83)) # 0.9.0 (September 09, 2020) BREAKING CHANGES: - - `context.Context` added to `tfinstall.Find` to allow for cancellation, timeouts, etc ([#51](https://github.com/hashicorp/terraform-exec/issues/51)) - - You can no longer use `TF_WORKSPACE` for workspace management, you must use `Terraform.WorkspaceSelect` ([#75](https://github.com/hashicorp/terraform-exec/issues/75)) +- `context.Context` added to `tfinstall.Find` to allow for cancellation, timeouts, etc ([#51](https://github.com/hashicorp/terraform-exec/issues/51)) +- You can no longer use `TF_WORKSPACE` for workspace management, you must use `Terraform.WorkspaceSelect` ([#75](https://github.com/hashicorp/terraform-exec/issues/75)) FEATURES: - - Add `ErrWorkspaceExists` for when workspaces with the same name already exist when calling `Terraform.WorkspaceNew` ([#67](https://github.com/hashicorp/terraform-exec/issues/67)) - - Added `tfinstall.GitRef` to support installation of Terraform from a git ref instead of by released version ([#51](https://github.com/hashicorp/terraform-exec/issues/51)) - - Created the **tfinstall** CLI utility (this is mostly for use in things like CI automation) ([#29](https://github.com/hashicorp/terraform-exec/issues/29)) - - Added `ReattachOption` for plugin reattach functionality ([#78](https://github.com/hashicorp/terraform-exec/issues/78)) +- Add `ErrWorkspaceExists` for when workspaces with the same name already exist when calling `Terraform.WorkspaceNew` ([#67](https://github.com/hashicorp/terraform-exec/issues/67)) +- Added `tfinstall.GitRef` to support installation of Terraform from a git ref instead of by released version ([#51](https://github.com/hashicorp/terraform-exec/issues/51)) +- Created the **tfinstall** CLI utility (this is mostly for use in things like CI automation) ([#29](https://github.com/hashicorp/terraform-exec/issues/29)) +- Added `ReattachOption` for plugin reattach functionality ([#78](https://github.com/hashicorp/terraform-exec/issues/78)) # 0.8.0 (August 29, 2020) BREAKING CHANGES: - - Add `-detailed-exit-code` to `Terraform.Plan` calls, `Terraform.Plan` now also returns a bool indicating if any diff is present ([#55](https://github.com/hashicorp/terraform-exec/issues/55)) - +- Add `-detailed-exit-code` to `Terraform.Plan` calls, `Terraform.Plan` now also returns a bool indicating if any diff is present ([#55](https://github.com/hashicorp/terraform-exec/issues/55)) + FEATURES: - - Added `Terraform.SetAppendUserAgent` for User-Agent management from consuming applications ([#46](https://github.com/hashicorp/terraform-exec/issues/46)) - - Added `Terraform.WorkspaceList`, `Terraform.WorkspaceNew`, and `Terraform.WorkspaceSelect` along with the `ErrNoWorkspace` error to indicate a workspace does not exist ([#56](https://github.com/hashicorp/terraform-exec/issues/56)) - - Added support for using multiple `VarFile` options ([#61](https://github.com/hashicorp/terraform-exec/issues/61)) - +- Added `Terraform.SetAppendUserAgent` for User-Agent management from consuming applications ([#46](https://github.com/hashicorp/terraform-exec/issues/46)) +- Added `Terraform.WorkspaceList`, `Terraform.WorkspaceNew`, and `Terraform.WorkspaceSelect` along with the `ErrNoWorkspace` error to indicate a workspace does not exist ([#56](https://github.com/hashicorp/terraform-exec/issues/56)) +- Added support for using multiple `VarFile` options ([#61](https://github.com/hashicorp/terraform-exec/issues/61)) + BUG FIXES: - - Fix bug with checking for empty path before executing version command ([#62](https://github.com/hashicorp/terraform-exec/issues/62)) +- Fix bug with checking for empty path before executing version command ([#62](https://github.com/hashicorp/terraform-exec/issues/62)) # 0.7.0 (August 20, 2020) FEATURES: - - Added `Terraform.Refresh` method ([#53](https://github.com/hashicorp/terraform-exec/issues/53)) - - Added `Terraform.ShowStateFile` and `Terraform.ShowPlanFile` ([#54](https://github.com/hashicorp/terraform-exec/issues/54)) - - Added support for `DIR` positional arg in init, destroy, and plan ([#52](https://github.com/hashicorp/terraform-exec/issues/52)) - - Relaxed logger interface ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) - - Added error for missing required variable ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) +- Added `Terraform.Refresh` method ([#53](https://github.com/hashicorp/terraform-exec/issues/53)) +- Added `Terraform.ShowStateFile` and `Terraform.ShowPlanFile` ([#54](https://github.com/hashicorp/terraform-exec/issues/54)) +- Added support for `DIR` positional arg in init, destroy, and plan ([#52](https://github.com/hashicorp/terraform-exec/issues/52)) +- Relaxed logger interface ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) +- Added error for missing required variable ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) BUG FIXES: - - Fixed logging issue for error cmd ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) +- Fixed logging issue for error cmd ([#57](https://github.com/hashicorp/terraform-exec/issues/57)) # 0.6.0 (August 14, 2020) FEATURES: - - Added `Terraform.SetStdout` and `Terraform.SetStderr` to let consumers log CLI output ([#49](https://github.com/hashicorp/terraform-exec/issues/49)) +- Added `Terraform.SetStdout` and `Terraform.SetStderr` to let consumers log CLI output ([#49](https://github.com/hashicorp/terraform-exec/issues/49)) BUG FIXES: - - Fixed miscategorization of `ErrNoInit` on Terraform 0.13 ([#48](https://github.com/hashicorp/terraform-exec/issues/48)) +- Fixed miscategorization of `ErrNoInit` on Terraform 0.13 ([#48](https://github.com/hashicorp/terraform-exec/issues/48)) # 0.5.0 (August 14, 2020) FEATURES: - - Version compatibility testing for `terraform show` ([#41](https://github.com/hashicorp/terraform-exec/issues/41)) +- Version compatibility testing for `terraform show` ([#41](https://github.com/hashicorp/terraform-exec/issues/41)) BUG FIXES: - - Tolerate reversed `terraform version` output order ([#47](https://github.com/hashicorp/terraform-exec/issues/47)) +- Tolerate reversed `terraform version` output order ([#47](https://github.com/hashicorp/terraform-exec/issues/47)) # 0.4.0 (July 30, 2020) FEATURES: - - Added `Terraform.SetLogPath` method to set `TF_LOG_PATH` environment variable, and prevented manual setting of programmatically supported environment variables ([#32](https://github.com/hashicorp/terraform-exec/issues/32)) - - Added `Terraform.Version` method to get executable version information ([#7](https://github.com/hashicorp/terraform-exec/issues/7)) +- Added `Terraform.SetLogPath` method to set `TF_LOG_PATH` environment variable, and prevented manual setting of programmatically supported environment variables ([#32](https://github.com/hashicorp/terraform-exec/issues/32)) +- Added `Terraform.Version` method to get executable version information ([#7](https://github.com/hashicorp/terraform-exec/issues/7)) BUG FIXES: - - Fixed `-var` handling issue ([#34](https://github.com/hashicorp/terraform-exec/issues/34)) +- Fixed `-var` handling issue ([#34](https://github.com/hashicorp/terraform-exec/issues/34)) # 0.3.0 (July 17, 2020) BREAKING CHANGES: - - Stop exporting `exec.Cmd` versions of methods ([#25](https://github.com/hashicorp/terraform-exec/issues/25)) - - Require `address` and `id` arguments in `Import()` ([#24](https://github.com/hashicorp/terraform-exec/issues/24)) - - Rename `StateShow()` to `Show()` ([#30](https://github.com/hashicorp/terraform-exec/issues/30)) +- Stop exporting `exec.Cmd` versions of methods ([#25](https://github.com/hashicorp/terraform-exec/issues/25)) +- Require `address` and `id` arguments in `Import()` ([#24](https://github.com/hashicorp/terraform-exec/issues/24)) +- Rename `StateShow()` to `Show()` ([#30](https://github.com/hashicorp/terraform-exec/issues/30)) BUG FIXES: - - Fix bug in `Import()` config argument ([#28](https://github.com/hashicorp/terraform-exec/issues/28)) +- Fix bug in `Import()` config argument ([#28](https://github.com/hashicorp/terraform-exec/issues/28)) # 0.2.2 (July 13, 2020) BUG FIXES: - - Version number is now correctly reported by the tfinstall package. Please note that `tfinstall.Version` was incorrect between versions 0.1.1 and 0.2.1 inclusive. +- Version number is now correctly reported by the tfinstall package. Please note that `tfinstall.Version` was incorrect between versions 0.1.1 and 0.2.1 inclusive. # 0.2.1 (July 10, 2020) BUG FIXES: - - Minor code changes to allow for compilation in Go 1.12 ([#21](https://github.com/hashicorp/terraform-exec/pull/21)) +- Minor code changes to allow for compilation in Go 1.12 ([#21](https://github.com/hashicorp/terraform-exec/pull/21)) # 0.2.0 (July 8, 2020) FEATURES: - - add `Import()` function ([#20](https://github.com/hashicorp/terraform-exec/pull/20)) +- add `Import()` function ([#20](https://github.com/hashicorp/terraform-exec/pull/20)) # 0.1.1 (July 7, 2020) BUG FIXES: - - Downgrade `github.com/hashicorp/go-getter` dependency, which added a requirement for Go 1.13. +- Downgrade `github.com/hashicorp/go-getter` dependency, which added a requirement for Go 1.13. # 0.1.0 (July 3, 2020) diff --git a/tfexec/apply_test.go b/tfexec/apply_test.go index a790359c..1cf2f562 100644 --- a/tfexec/apply_test.go +++ b/tfexec/apply_test.go @@ -43,6 +43,7 @@ func TestApplyCmd(t *testing.T) { assertCmd(t, []string{ "apply", + "-no-color", "-auto-approve", "-input=false", "-backup=testbackup", @@ -61,7 +62,6 @@ func TestApplyCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "testfile", - "-no-color", }, nil, applyCmd) }) } diff --git a/tfexec/cmd.go b/tfexec/cmd.go index 11a56510..23a9a3cd 100644 --- a/tfexec/cmd.go +++ b/tfexec/cmd.go @@ -181,10 +181,10 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string { func (tf *Terraform) buildTerraformCmd(ctx context.Context, mergeEnv map[string]string, args ...string) *exec.Cmd { if !tf.colors { - args = append(args, "-no-color") + args = addColorFlag(args) } - cmd := exec.Command(tf.execPath, args...) + cmd := exec.CommandContext(ctx, tf.execPath, args...) cmd.Env = tf.buildEnv(mergeEnv) cmd.Dir = tf.workingDir @@ -194,6 +194,36 @@ func (tf *Terraform) buildTerraformCmd(ctx context.Context, mergeEnv map[string] return cmd } +func addColorFlag(args []string) []string { + found := false + insertIndex := 0 + for i, a := range args { + if strings.HasPrefix(a, "-") && insertIndex == 0 { + insertIndex = i + } + + if a == "-no-color" { + found = true + } + } + if insertIndex == 0 { + insertIndex = len(args) + } + if !found { + args = insert(args, insertIndex, "-no-color") + } + return args +} + +func insert(a []string, index int, value string) []string { + if len(a) == index { + return append(a, value) + } + a = append(a[:index+1], a[index:]...) + a[index] = value + return a +} + func (tf *Terraform) runTerraformCmdJSON(ctx context.Context, cmd *exec.Cmd, v interface{}) error { var outbuf = bytes.Buffer{} cmd.Stdout = mergeWriters(cmd.Stdout, &outbuf) diff --git a/tfexec/destroy_test.go b/tfexec/destroy_test.go index 8d1b91ce..eb28f58a 100644 --- a/tfexec/destroy_test.go +++ b/tfexec/destroy_test.go @@ -26,13 +26,13 @@ func TestDestroyCmd(t *testing.T) { assertCmd(t, []string{ "destroy", + "-no-color", "-auto-approve", "-input=false", "-lock-timeout=0s", "-lock=true", "-parallelism=10", "-refresh=true", - "-no-color", }, nil, destroyCmd) }) @@ -44,6 +44,7 @@ func TestDestroyCmd(t *testing.T) { assertCmd(t, []string{ "destroy", + "-no-color", "-auto-approve", "-input=false", "-backup=testbackup", @@ -59,7 +60,6 @@ func TestDestroyCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "destroydir", - "-no-color", }, nil, destroyCmd) }) } diff --git a/tfexec/get_test.go b/tfexec/get_test.go index 1fde9804..32cfbe0c 100644 --- a/tfexec/get_test.go +++ b/tfexec/get_test.go @@ -26,8 +26,8 @@ func TestGetCmd(t *testing.T) { assertCmd(t, []string{ "get", - "-update=false", "-no-color", + "-update=false", }, nil, getCmd) }) } diff --git a/tfexec/graph_test.go b/tfexec/graph_test.go index 3782faad..77bb5c37 100644 --- a/tfexec/graph_test.go +++ b/tfexec/graph_test.go @@ -41,9 +41,9 @@ func TestGraphCmd_v013(t *testing.T) { assertCmd(t, []string{ "graph", "teststate", + "-no-color", "-draw-cycles", "-type=output", - "-no-color", }, nil, graphCmd) }) } @@ -76,10 +76,10 @@ func TestGraphCmd_v1(t *testing.T) { assertCmd(t, []string{ "graph", + "-no-color", "-plan=teststate", "-draw-cycles", "-type=output", - "-no-color", }, nil, graphCmd) }) } diff --git a/tfexec/import_test.go b/tfexec/import_test.go index 8a88551c..e1d5d6d7 100644 --- a/tfexec/import_test.go +++ b/tfexec/import_test.go @@ -26,12 +26,12 @@ func TestImportCmd(t *testing.T) { assertCmd(t, []string{ "import", + "-no-color", "-input=false", "-lock-timeout=0s", "-lock=true", "my-addr", "my-id", - "-no-color", }, nil, importCmd) }) @@ -53,6 +53,7 @@ func TestImportCmd(t *testing.T) { assertCmd(t, []string{ "import", + "-no-color", "-input=false", "-backup=testbackup", "-lock-timeout=200s", @@ -65,7 +66,6 @@ func TestImportCmd(t *testing.T) { "-var", "var2=bar", "my-addr2", "my-id2", - "-no-color", }, nil, importCmd) }) } diff --git a/tfexec/init_test.go b/tfexec/init_test.go index 2f36e67a..e1bcb86d 100644 --- a/tfexec/init_test.go +++ b/tfexec/init_test.go @@ -32,6 +32,7 @@ func TestInitCmd_v012(t *testing.T) { assertCmd(t, []string{ "init", + "-no-color", "-force-copy", "-input=false", "-lock-timeout=0s", @@ -41,7 +42,6 @@ func TestInitCmd_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", - "-no-color", }, nil, initCmd) }) @@ -53,6 +53,7 @@ func TestInitCmd_v012(t *testing.T) { assertCmd(t, []string{ "init", + "-no-color", "-force-copy", "-input=false", "-from-module=testsource", @@ -70,7 +71,6 @@ func TestInitCmd_v012(t *testing.T) { "-plugin-dir=testdir1", "-plugin-dir=testdir2", "initdir", - "-no-color", }, nil, initCmd) }) } diff --git a/tfexec/output_test.go b/tfexec/output_test.go index 6733e602..1df7a58c 100644 --- a/tfexec/output_test.go +++ b/tfexec/output_test.go @@ -23,8 +23,8 @@ func TestOutputCmd(t *testing.T) { assertCmd(t, []string{ "output", - "-json", "-no-color", + "-json", }, nil, outputCmd) }) @@ -34,9 +34,9 @@ func TestOutputCmd(t *testing.T) { assertCmd(t, []string{ "output", + "-no-color", "-json", "-state=teststate", - "-no-color", }, nil, outputCmd) }) } diff --git a/tfexec/plan_test.go b/tfexec/plan_test.go index eda22393..7a467ac3 100644 --- a/tfexec/plan_test.go +++ b/tfexec/plan_test.go @@ -26,13 +26,13 @@ func TestPlanCmd(t *testing.T) { assertCmd(t, []string{ "plan", + "-no-color", "-input=false", "-detailed-exitcode", "-lock-timeout=0s", "-lock=true", "-parallelism=10", "-refresh=true", - "-no-color", }, nil, planCmd) }) @@ -59,6 +59,7 @@ func TestPlanCmd(t *testing.T) { assertCmd(t, []string{ "plan", + "-no-color", "-input=false", "-detailed-exitcode", "-lock-timeout=22s", @@ -76,7 +77,6 @@ func TestPlanCmd(t *testing.T) { "-var", "android=paranoid", "-var", "brain_size=planet", "earth", - "-no-color", }, nil, planCmd) }) } diff --git a/tfexec/providers_lock_test.go b/tfexec/providers_lock_test.go index c46fc124..755a2a35 100644 --- a/tfexec/providers_lock_test.go +++ b/tfexec/providers_lock_test.go @@ -34,11 +34,11 @@ func TestProvidersLockCmd(t *testing.T) { assertCmd(t, []string{ "providers", "lock", + "-no-color", "-fs-mirror=test", "-net-mirror=test", "-platform=linux_amd64", "workingdir", - "-no-color", }, nil, lockCmd) }) } diff --git a/tfexec/providers_schema_test.go b/tfexec/providers_schema_test.go index 33cff78c..f4b5ac23 100644 --- a/tfexec/providers_schema_test.go +++ b/tfexec/providers_schema_test.go @@ -23,7 +23,7 @@ func TestProvidersSchemaCmd(t *testing.T) { assertCmd(t, []string{ "providers", "schema", - "-json", "-no-color", + "-json", }, nil, schemaCmd) } diff --git a/tfexec/refresh_test.go b/tfexec/refresh_test.go index b2179146..bd4a94c4 100644 --- a/tfexec/refresh_test.go +++ b/tfexec/refresh_test.go @@ -26,10 +26,10 @@ func TestRefreshCmd(t *testing.T) { assertCmd(t, []string{ "refresh", + "-no-color", "-input=false", "-lock-timeout=0s", "-lock=true", - "-no-color", }, nil, refreshCmd) }) @@ -41,6 +41,7 @@ func TestRefreshCmd(t *testing.T) { assertCmd(t, []string{ "refresh", + "-no-color", "-input=false", "-backup=testbackup", "-lock-timeout=200s", @@ -53,7 +54,6 @@ func TestRefreshCmd(t *testing.T) { "-var", "var1=foo", "-var", "var2=bar", "refreshdir", - "-no-color", }, nil, refreshCmd) }) } diff --git a/tfexec/show_test.go b/tfexec/show_test.go index 37f5635f..5685d099 100644 --- a/tfexec/show_test.go +++ b/tfexec/show_test.go @@ -23,8 +23,8 @@ func TestShowCmd(t *testing.T) { assertCmd(t, []string{ "show", - "-json", "-no-color", + "-json", }, nil, showCmd) } @@ -43,9 +43,9 @@ func TestShowStateFileCmd(t *testing.T) { assertCmd(t, []string{ "show", + "-no-color", "-json", "statefilepath", - "-no-color", }, nil, showCmd) } @@ -64,9 +64,9 @@ func TestShowPlanFileCmd(t *testing.T) { assertCmd(t, []string{ "show", + "-no-color", "-json", "planfilepath", - "-no-color", }, nil, showCmd) } diff --git a/tfexec/state_mv_test.go b/tfexec/state_mv_test.go index 08a58ddb..47597693 100644 --- a/tfexec/state_mv_test.go +++ b/tfexec/state_mv_test.go @@ -27,11 +27,11 @@ func TestStateMvCmd(t *testing.T) { assertCmd(t, []string{ "state", "mv", + "-no-color", "-lock-timeout=0s", "-lock=true", "testsource", "testdestination", - "-no-color", }, nil, stateMvCmd) }) @@ -44,6 +44,7 @@ func TestStateMvCmd(t *testing.T) { assertCmd(t, []string{ "state", "mv", + "-no-color", "-backup=testbackup", "-backup-out=testbackupout", "-lock-timeout=200s", @@ -52,7 +53,6 @@ func TestStateMvCmd(t *testing.T) { "-lock=false", "testsrc", "testdest", - "-no-color", }, nil, stateMvCmd) }) } diff --git a/tfexec/state_pull_test.go b/tfexec/state_pull_test.go index 4a26ef11..a0c9664e 100644 --- a/tfexec/state_pull_test.go +++ b/tfexec/state_pull_test.go @@ -21,6 +21,7 @@ func TestStatePull(t *testing.T) { assertCmd(t, []string{ "state", "pull", + "-no-color", }, nil, statePullCmd) }) } diff --git a/tfexec/state_push_test.go b/tfexec/state_push_test.go index 075c33a2..71847cd3 100644 --- a/tfexec/state_push_test.go +++ b/tfexec/state_push_test.go @@ -24,6 +24,7 @@ func TestStatePushCmd(t *testing.T) { assertCmd(t, []string{ "state", "push", + "-no-color", "-lock=false", "-lock-timeout=0s", "testpath", @@ -39,6 +40,7 @@ func TestStatePushCmd(t *testing.T) { assertCmd(t, []string{ "state", "push", + "-no-color", "-force", "-lock=true", "-lock-timeout=10s", diff --git a/tfexec/state_rm_test.go b/tfexec/state_rm_test.go index f61b301e..0a7843bd 100644 --- a/tfexec/state_rm_test.go +++ b/tfexec/state_rm_test.go @@ -27,10 +27,10 @@ func TestStateRmCmd(t *testing.T) { assertCmd(t, []string{ "state", "rm", + "-no-color", "-lock-timeout=0s", "-lock=true", "testAddress", - "-no-color", }, nil, stateRmCmd) }) @@ -43,6 +43,7 @@ func TestStateRmCmd(t *testing.T) { assertCmd(t, []string{ "state", "rm", + "-no-color", "-backup=testbackup", "-backup-out=testbackupout", "-lock-timeout=200s", @@ -50,7 +51,6 @@ func TestStateRmCmd(t *testing.T) { "-state-out=teststateout", "-lock=false", "testAddress", - "-no-color", }, nil, stateRmCmd) }) } diff --git a/tfexec/taint_test.go b/tfexec/taint_test.go index 49a22e45..ed0ec695 100644 --- a/tfexec/taint_test.go +++ b/tfexec/taint_test.go @@ -23,9 +23,9 @@ func TestTaintCmd(t *testing.T) { assertCmd(t, []string{ "taint", + "-no-color", "-lock=true", "aws_instance.foo", - "-no-color", }, nil, taintCmd) }) @@ -38,12 +38,12 @@ func TestTaintCmd(t *testing.T) { assertCmd(t, []string{ "taint", + "-no-color", "-lock-timeout=200s", "-state=teststate", "-lock=false", "-allow-missing", "aws_instance.foo", - "-no-color", }, nil, taintCmd) }) } diff --git a/tfexec/terraform_test.go b/tfexec/terraform_test.go index 7caeeff9..34b45823 100644 --- a/tfexec/terraform_test.go +++ b/tfexec/terraform_test.go @@ -694,6 +694,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { assertCmd(t, []string{ "init", + "-no-color", "-force-copy", "-input=false", "-lock-timeout=0s", @@ -703,7 +704,6 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", - "-no-color", }, map[string]string{ "CHECKPOINT_DISABLE": "1", "FOOBAR": "1", @@ -726,6 +726,7 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { assertCmd(t, []string{ "init", + "-no-color", "-force-copy", "-input=false", "-lock-timeout=0s", @@ -735,7 +736,6 @@ func TestCheckpointDisablePropagation_v012(t *testing.T) { "-lock=true", "-get-plugins=true", "-verify-plugins=true", - "-no-color", }, map[string]string{ "CHECKPOINT_DISABLE": "", "FOOBAR": "2", diff --git a/tfexec/untaint_test.go b/tfexec/untaint_test.go index 801cc07e..cfe9085f 100644 --- a/tfexec/untaint_test.go +++ b/tfexec/untaint_test.go @@ -23,9 +23,9 @@ func TestUntaintCmd(t *testing.T) { assertCmd(t, []string{ "untaint", + "-no-color", "-lock=true", "aws_instance.foo", - "-no-color", }, nil, untaintCmd) }) @@ -38,12 +38,12 @@ func TestUntaintCmd(t *testing.T) { assertCmd(t, []string{ "untaint", + "-no-color", "-lock-timeout=200s", "-state=teststate", "-lock=false", "-allow-missing", "aws_instance.foo", - "-no-color", }, nil, untaintCmd) }) } diff --git a/tfexec/upgrade012_test.go b/tfexec/upgrade012_test.go index 7b5fff4a..71fc606e 100644 --- a/tfexec/upgrade012_test.go +++ b/tfexec/upgrade012_test.go @@ -33,8 +33,8 @@ func TestUpgrade012(t *testing.T) { assertCmd(t, []string{ "0.12upgrade", - "-yes", "-no-color", + "-yes", }, nil, upgrade012Cmd) }) @@ -54,10 +54,10 @@ func TestUpgrade012(t *testing.T) { assertCmd(t, []string{ "0.12upgrade", + "-no-color", "-yes", "-force", "upgrade012dir", - "-no-color", }, nil, upgrade012Cmd) }) diff --git a/tfexec/upgrade013_test.go b/tfexec/upgrade013_test.go index 0f510cff..5704f274 100644 --- a/tfexec/upgrade013_test.go +++ b/tfexec/upgrade013_test.go @@ -33,8 +33,8 @@ func TestUpgrade013(t *testing.T) { assertCmd(t, []string{ "0.13upgrade", - "-yes", "-no-color", + "-yes", }, nil, upgrade013Cmd) }) @@ -54,9 +54,9 @@ func TestUpgrade013(t *testing.T) { assertCmd(t, []string{ "0.13upgrade", + "-no-color", "-yes", "upgrade013dir", - "-no-color", }, nil, upgrade013Cmd) }) diff --git a/tfexec/workspace_delete_test.go b/tfexec/workspace_delete_test.go index 4aaf6790..a1cb1d02 100644 --- a/tfexec/workspace_delete_test.go +++ b/tfexec/workspace_delete_test.go @@ -23,7 +23,8 @@ func TestWorkspaceDeleteCmd(t *testing.T) { } assertCmd(t, []string{ - "workspace", "delete", + "workspace", + "delete", "workspace-name", "-no-color", }, nil, workspaceDeleteCmd) @@ -39,12 +40,13 @@ func TestWorkspaceDeleteCmd(t *testing.T) { } assertCmd(t, []string{ - "workspace", "delete", + "workspace", + "delete", + "-no-color", "-force", "-lock-timeout=200s", "-lock=false", "workspace-name", - "-no-color", }, nil, workspaceDeleteCmd) }) } diff --git a/tfexec/workspace_new_test.go b/tfexec/workspace_new_test.go index e20b7873..da7418b4 100644 --- a/tfexec/workspace_new_test.go +++ b/tfexec/workspace_new_test.go @@ -32,7 +32,8 @@ func TestWorkspaceNewCmd(t *testing.T) { } assertCmd(t, []string{ - "workspace", "new", + "workspace", + "new", "workspace-name", "-no-color", }, nil, workspaceNewCmd) @@ -45,12 +46,13 @@ func TestWorkspaceNewCmd(t *testing.T) { } assertCmd(t, []string{ - "workspace", "new", + "workspace", + "new", + "-no-color", "-lock-timeout=200s", "-lock=false", "-state=teststate", "workspace-name", - "-no-color", }, nil, workspaceNewCmd) }) }