Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kumactl) Check version after loading config. #1879

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions app/kumactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ func NewRootCmd(root *kumactl_cmd.RootContext) *cobra.Command {
Short: "Management tool for Kuma",
Long: `Management tool for Kuma.`,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
client, err := root.CurrentApiClient()
if err != nil {
kumactlLog.Error(err, "Unable to get index client")
} else {
kumaBuildVersion, _ = client.GetVersion()
}
level, err := kuma_log.ParseLogLevel(args.logLevel)
if err != nil {
return err
Expand All @@ -57,16 +51,28 @@ func NewRootCmd(root *kumactl_cmd.RootContext) *cobra.Command {
// once command line flags have been parsed,
// avoid printing usage instructions
cmd.SilenceUsage = true
if kumaBuildVersion != nil && kumaBuildVersion.Version != kuma_version.Build.Version {
cmd.Println("Warning: Your kumactl version is " + kuma_version.Build.Version + " which is not the same as " + kumaBuildVersion.Version + " for CP. Update your kumactl.")
}
if root.IsFirstTimeUsage() {
root.Runtime.Config = kumactl_config.DefaultConfiguration()
if err := root.SaveConfig(); err != nil {
return err
}
}
return root.LoadConfig()

if err := root.LoadConfig(); err != nil {
return err
}

client, err := root.CurrentApiClient()
if err != nil {
kumactlLog.Error(err, "Unable to get index client")
} else {
kumaBuildVersion, _ = client.GetVersion()
}

if kumaBuildVersion != nil && (kumaBuildVersion.Version != kuma_version.Build.Version || kumaBuildVersion.Tagline != kuma_version.Product) {
cmd.PrintErr("WARNING: You are using kumactl version " + kuma_version.Build.Version + " for " + kuma_version.Product + ", but the server returned version: " + kumaBuildVersion.Tagline + " " + kumaBuildVersion.Version + "\n")
}
return nil
},
}
// root flags
Expand Down