Skip to content

Commit

Permalink
fix: cli disable get config for cload context (#4583)
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv authored Nov 8, 2023
1 parent 2405a1a commit ce809f1
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cmd/kubectl-testkube/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,27 @@ var RootCmd = &cobra.Command{
if err != nil {
return
}
// We ignore this check for cloud, since agent can be offline, and config API won't work
// but other commands should work.
if clientCfg.ContextType != config.ContextTypeCloud {
serverCfg, err := client.GetConfig()
if ui.Verbose && err != nil {
ui.Err(err)
}

serverCfg, err := client.GetConfig()
if ui.Verbose && err != nil {
ui.Err(err)
}
if clientCfg.TelemetryEnabled != serverCfg.EnableTelemetry && err == nil {
if serverCfg.EnableTelemetry {
clientCfg.EnableAnalytics()
ui.Debug("Sync telemetry on CLI with API", "enabled")
} else {
clientCfg.DisableAnalytics()
ui.Debug("Sync telemetry on CLI with API", "disabled")
}

if clientCfg.TelemetryEnabled != serverCfg.EnableTelemetry && err == nil {
if serverCfg.EnableTelemetry {
clientCfg.EnableAnalytics()
ui.Debug("Sync telemetry on CLI with API", "enabled")
} else {
clientCfg.DisableAnalytics()
ui.Debug("Sync telemetry on CLI with API", "disabled")
err = config.Save(clientCfg)
ui.WarnOnError("syncing config", err)
}

err = config.Save(clientCfg)
ui.WarnOnError("syncing config", err)
}

if clientCfg.TelemetryEnabled {
ui.Debug("collecting anonymous telemetry data, you can disable it by calling `kubectl testkube disable telemetry`")
out, err := telemetry.SendCmdEvent(cmd, common.Version)
Expand Down

0 comments on commit ce809f1

Please sign in to comment.