github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/version.go (about) 1 package commands 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/commands/common/validator" 8 "github.com/kubeshop/testkube/cmd/kubectl-testkube/config" 9 "github.com/kubeshop/testkube/pkg/ui" 10 ) 11 12 func NewVersionCmd() *cobra.Command { 13 return &cobra.Command{ 14 Use: "version", 15 Aliases: []string{"v"}, 16 Short: "Shows version and build info", 17 Long: `Shows version and build info`, 18 Run: func(cmd *cobra.Command, args []string) { 19 client, _, err := common.GetClient(cmd) 20 ui.ExitOnError("getting client", err) 21 22 info, err := client.GetServerInfo() 23 if err != nil { 24 info.Version = info.Version + " " + err.Error() 25 } 26 27 ui.Logo() 28 ui.Info("Client Version", common.Version) 29 ui.Info("Server Version", info.Version) 30 ui.Info("Commit", common.Commit) 31 ui.Info("Built by", common.BuiltBy) 32 ui.Info("Build date", common.Date) 33 34 }, 35 PersistentPreRun: func(cmd *cobra.Command, args []string) { 36 cfg, err := config.Load() 37 ui.ExitOnError("loading config", err) 38 common.UiContextHeader(cmd, cfg) 39 40 validator.PersistentPreRunVersionCheck(cmd, common.Version) 41 }, 42 } 43 }