github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/get.go (about) 1 package commands 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/artifacts" 7 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common" 8 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/validator" 9 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/context" 10 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/executors" 11 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/templates" 12 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/tests" 13 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testsources" 14 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testsuites" 15 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testworkflows" 16 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testworkflowtemplates" 17 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/webhooks" 18 "github.com/kubeshop/testkube/cmd/kubectl-testkube/config" 19 "github.com/kubeshop/testkube/pkg/ui" 20 ) 21 22 func NewGetCmd() *cobra.Command { 23 cmd := &cobra.Command{ 24 Use: "get <resourceName>", 25 Aliases: []string{"g"}, 26 Short: "Get resources", 27 Long: `Get available resources, get single item or list`, 28 Annotations: map[string]string{cmdGroupAnnotation: cmdGroupCommands}, 29 Run: func(cmd *cobra.Command, args []string) { 30 err := cmd.Help() 31 ui.PrintOnError("Displaying help", err) 32 }, 33 PersistentPreRun: func(cmd *cobra.Command, args []string) { 34 cfg, err := config.Load() 35 ui.ExitOnError("loading config", err) 36 common.UiContextHeader(cmd, cfg) 37 38 validator.PersistentPreRunVersionCheck(cmd, common.Version) 39 40 }, 41 } 42 43 cmd.AddCommand(tests.NewGetTestsCmd()) 44 cmd.AddCommand(testsuites.NewGetTestSuiteCmd()) 45 cmd.AddCommand(webhooks.NewGetWebhookCmd()) 46 cmd.AddCommand(executors.NewGetExecutorCmd()) 47 cmd.AddCommand(tests.NewGetExecutionCmd()) 48 cmd.AddCommand(artifacts.NewListArtifactsCmd()) 49 cmd.AddCommand(testsuites.NewTestSuiteExecutionCmd()) 50 cmd.AddCommand(testsources.NewGetTestSourceCmd()) 51 cmd.AddCommand(context.NewGetContextCmd()) 52 cmd.AddCommand(templates.NewGetTemplateCmd()) 53 cmd.AddCommand(testworkflows.NewGetTestWorkflowsCmd()) 54 cmd.AddCommand(testworkflows.NewGetTestWorkflowExecutionsCmd()) 55 cmd.AddCommand(testworkflowtemplates.NewGetTestWorkflowTemplatesCmd()) 56 57 cmd.PersistentFlags().StringP("output", "o", "pretty", "output type can be one of json|yaml|pretty|go-template") 58 cmd.PersistentFlags().StringP("go-template", "", "{{.}}", "go template to render") 59 60 return cmd 61 }