Skip to content

Commit

Permalink
fix panic when reading from context
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun committed Dec 16, 2024
1 parent 0662bec commit 7c8ad62
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,13 @@ func customHelpMessageToUpgradeToAtmosLatestRelease(cmd *cobra.Command, args []s
if value == nil {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("atmos configuration not found in context"))
}
atmosConfig := value.(*schema.CliConfiguration)
atmosConfig, ok := value.(schema.CliConfiguration)
if !ok {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("invalid atmos configuration type in context"))
}

originalHelpFunc(cmd, args)
CheckForAtmosUpdateAndPrintMessage(*atmosConfig)
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
}

// Check Atmos is version command
Expand Down
7 changes: 5 additions & 2 deletions cmd/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ var helmfileCmd = &cobra.Command{
if value == nil {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("atmos configuration not found in context"))
}
atmosConfig := value.(*schema.CliConfiguration)
atmosConfig, ok := value.(schema.CliConfiguration)
if !ok {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("invalid atmos configuration type in context"))
}

CheckForAtmosUpdateAndPrintMessage(*atmosConfig)
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
return
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ var terraformCmd = &cobra.Command{
if value == nil {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("atmos configuration not found in context"))
}
atmosConfig := value.(*schema.CliConfiguration)
atmosConfig, ok := value.(schema.CliConfiguration)
if !ok {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("invalid atmos configuration type in context"))
}

CheckForAtmosUpdateAndPrintMessage(*atmosConfig)
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
return
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ var versionCmd = &cobra.Command{
if value == nil {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("atmos configuration not found in context"))
}
atmosConfig := value.(*schema.CliConfiguration)
CheckForAtmosUpdateAndPrintMessage(*atmosConfig)
atmosConfig, ok := value.(schema.CliConfiguration)
if !ok {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("invalid atmos configuration type in context"))
}
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
},
}

Expand Down

0 comments on commit 7c8ad62

Please sign in to comment.