From e4dd8492d93452e6d2acf324303cfae1ca00fb0b Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 12 Dec 2024 12:12:45 +0100 Subject: [PATCH 1/2] add support for terraform version --- internal/exec/terraform.go | 9 +++++++++ internal/exec/utils.go | 13 +++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/internal/exec/terraform.go b/internal/exec/terraform.go index c0d53700d..4d9bb1f28 100644 --- a/internal/exec/terraform.go +++ b/internal/exec/terraform.go @@ -61,6 +61,15 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error { fmt.Println() return nil } + if info.SubCommand == "version" { + return ExecuteShellCommand(cliConfig, + "terraform", + []string{info.SubCommand}, + "", + nil, + false, + info.RedirectStdErr) + } shouldProcessStacks := true shouldCheckStack := true diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 6fefa53ba..46693a4ba 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -661,22 +661,19 @@ func processArgsAndFlags(componentType string, inputArgsAndFlags []string) (sche var indexesToRemove []int // For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help - if len(inputArgsAndFlags) == 1 { + if len(inputArgsAndFlags) == 1 && inputArgsAndFlags[0] != "version" { info.SubCommand = inputArgsAndFlags[0] info.NeedHelp = true return info, nil } - - // https://github.com/roboll/helmfile#cli-reference - var globalOptionsFlagIndex int - - // For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help - if len(inputArgsAndFlags) == 1 { + if len(inputArgsAndFlags) == 1 && inputArgsAndFlags[0] == "version" { info.SubCommand = inputArgsAndFlags[0] - info.NeedHelp = true return info, nil } + // https://github.com/roboll/helmfile#cli-reference + var globalOptionsFlagIndex int + for i, arg := range inputArgsAndFlags { if arg == cfg.GlobalOptionsFlag { globalOptionsFlagIndex = i + 1 From b40fcc4a82bff4d260a8570e099d7651ae07e78a Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 12 Dec 2024 12:12:45 +0100 Subject: [PATCH 2/2] add support for terraform version issue: https://linear.app/cloudposse/issue/DEV-2820/atmos-terraform-version-does-not-work --- internal/exec/terraform.go | 9 +++++++++ internal/exec/utils.go | 13 +++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/internal/exec/terraform.go b/internal/exec/terraform.go index c0d53700d..4d9bb1f28 100644 --- a/internal/exec/terraform.go +++ b/internal/exec/terraform.go @@ -61,6 +61,15 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error { fmt.Println() return nil } + if info.SubCommand == "version" { + return ExecuteShellCommand(cliConfig, + "terraform", + []string{info.SubCommand}, + "", + nil, + false, + info.RedirectStdErr) + } shouldProcessStacks := true shouldCheckStack := true diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 6fefa53ba..46693a4ba 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -661,22 +661,19 @@ func processArgsAndFlags(componentType string, inputArgsAndFlags []string) (sche var indexesToRemove []int // For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help - if len(inputArgsAndFlags) == 1 { + if len(inputArgsAndFlags) == 1 && inputArgsAndFlags[0] != "version" { info.SubCommand = inputArgsAndFlags[0] info.NeedHelp = true return info, nil } - - // https://github.com/roboll/helmfile#cli-reference - var globalOptionsFlagIndex int - - // For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help - if len(inputArgsAndFlags) == 1 { + if len(inputArgsAndFlags) == 1 && inputArgsAndFlags[0] == "version" { info.SubCommand = inputArgsAndFlags[0] - info.NeedHelp = true return info, nil } + // https://github.com/roboll/helmfile#cli-reference + var globalOptionsFlagIndex int + for i, arg := range inputArgsAndFlags { if arg == cfg.GlobalOptionsFlag { globalOptionsFlagIndex = i + 1