github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/update.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/commands/executors"
     9  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/templates"
    10  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/tests"
    11  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testsources"
    12  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/testsuites"
    13  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/webhooks"
    14  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
    15  	"github.com/kubeshop/testkube/pkg/ui"
    16  )
    17  
    18  func NewUpdateCmd() *cobra.Command {
    19  	cmd := &cobra.Command{
    20  		Use:         "update <resourceName>",
    21  		Aliases:     []string{"u"},
    22  		Short:       "Update resource",
    23  		Annotations: map[string]string{cmdGroupAnnotation: cmdGroupCommands},
    24  		Run: func(cmd *cobra.Command, args []string) {
    25  			err := cmd.Help()
    26  			ui.PrintOnError("Displaying help", err)
    27  		},
    28  		PersistentPreRun: func(cmd *cobra.Command, args []string) {
    29  			cfg, err := config.Load()
    30  			ui.ExitOnError("loading config", err)
    31  			common.UiContextHeader(cmd, cfg)
    32  
    33  			validator.PersistentPreRunVersionCheck(cmd, common.Version)
    34  		}}
    35  
    36  	cmd.AddCommand(tests.NewUpdateTestsCmd())
    37  	cmd.AddCommand(testsuites.UpdateTestSuitesCmd())
    38  	cmd.AddCommand(testsources.UpdateTestSourceCmd())
    39  	cmd.AddCommand(executors.UpdateExecutorCmd())
    40  	cmd.AddCommand(webhooks.UpdateWebhookCmd())
    41  	cmd.AddCommand(templates.UpdateTemplateCmd())
    42  
    43  	return cmd
    44  }