Skip to content

Commit

Permalink
fix check the version if config broken (#735)
Browse files Browse the repository at this point in the history
* modify error handling cli config

* add isVersionCommand

* modify the log error message

* Refactor logging in ExecuteAtmosVendorInternal function and modify log error message

---------

Co-authored-by: Andriy Knysh <[email protected]>
  • Loading branch information
haitham911 and aknysh authored Oct 25, 2024
1 parent 7e8d0af commit a29a413
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,8 @@ func printMessageToUpgradeToAtmosLatestRelease(latestVersion string) {
u.PrintMessageInColor("Install Atmos:\n", c2)
u.PrintMessage("https://atmos.tools/install\n")
}

// Check Atmos is version command
func isVersionCommand() bool {
return len(os.Args) > 1 && os.Args[1] == "version"
}
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func Execute() error {
// Here we need the custom commands from the config
cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
if err != nil && !errors.Is(err, cfg.NotFound) {
u.LogErrorAndExit(schema.CliConfiguration{}, err)
if isVersionCommand() {
u.LogTrace(schema.CliConfiguration{}, fmt.Sprintf("warning: CLI configuration 'atmos.yaml' file not found. Error: %s", err))
} else {
u.LogErrorAndExit(schema.CliConfiguration{}, err)
}
}

// If CLI configuration was found, process its custom commands and command aliases
Expand Down

0 comments on commit a29a413

Please sign in to comment.