From 11ec388215e672217428d8dcbf4d05b886bf6061 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sat, 14 Dec 2024 23:51:14 +0100 Subject: [PATCH] Add support for helmfile version command (#854) issue: https://linear.app/cloudposse/issue/DEV-2844/atmos-helmfile-version-does-not-work Co-authored-by: Andriy Knysh --- internal/exec/helmfile.go | 4 ++++ internal/exec/utils.go | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/exec/helmfile.go b/internal/exec/helmfile.go index bfcfde41a..fe36f7e9f 100644 --- a/internal/exec/helmfile.go +++ b/internal/exec/helmfile.go @@ -54,6 +54,10 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { return nil } + if info.SubCommand == "version" { + return ExecuteShellCommand(cliConfig, "helmfile", []string{info.SubCommand}, "", nil, false, info.RedirectStdErr) + } + info, err = ProcessStacks(cliConfig, info, true, true) if err != nil { return err 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