github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/agent/debug.go (about) 1 package agent 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common" 7 "github.com/kubeshop/testkube/cmd/kubectl-testkube/config" 8 "github.com/kubeshop/testkube/pkg/ui" 9 ) 10 11 func NewAgentDebugCmd() *cobra.Command { 12 13 cmd := &cobra.Command{ 14 Use: "debug", 15 Short: "Debug Agent info", 16 Run: func(cmd *cobra.Command, args []string) { 17 cfg, err := config.Load() 18 ui.ExitOnError("loading config file", err) 19 ui.NL() 20 21 if cfg.ContextType != config.ContextTypeCloud { 22 ui.Errf("Agent debug is only available for cloud context") 23 ui.NL() 24 ui.ShellCommand("Please try command below to set your context into Cloud mode", `testkube set context -o <org> -e <env> -k <api-key> `) 25 ui.NL() 26 return 27 } 28 29 common.UiPrintContext(cfg) 30 31 client, _, err := common.GetClient(cmd) 32 ui.ExitOnError("getting client", err) 33 34 i, err := client.GetServerInfo() 35 if err != nil { 36 ui.Errf("Error %v", err) 37 ui.NL() 38 ui.Info("Possible reasons:") 39 ui.Warn("- Please check if your agent organization and environment are set correctly") 40 ui.Warn("- Please check if your API token is set correctly") 41 ui.NL() 42 } else { 43 ui.Warn("Agent correctly connected to cloud:\n") 44 ui.InfoGrid(map[string]string{ 45 "Agent version ": i.Version, 46 "Agent namespace": i.Namespace, 47 }) 48 } 49 ui.NL() 50 }, 51 } 52 53 return cmd 54 }