github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/config.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  	commands "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/config"
     8  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/oauth"
     9  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
    10  	"github.com/kubeshop/testkube/pkg/ui"
    11  )
    12  
    13  func NewConfigCmd() *cobra.Command {
    14  	cmd := &cobra.Command{
    15  		Use:     "config <feature> <value>",
    16  		Aliases: []string{"set", "configure"},
    17  		Short:   "Set feature configuration value",
    18  		Run: func(cmd *cobra.Command, args []string) {
    19  			err := cmd.Help()
    20  			ui.PrintOnError("Displaying help", err)
    21  		},
    22  
    23  		PersistentPreRun: func(cmd *cobra.Command, args []string) {
    24  			cfg, err := config.Load()
    25  			ui.ExitOnError("loading config", err)
    26  			common.UiContextHeader(cmd, cfg)
    27  		},
    28  	}
    29  
    30  	cmd.AddCommand(commands.NewConfigureNamespaceCmd())
    31  	cmd.AddCommand(commands.NewConfigureAPIURICmd())
    32  	cmd.AddCommand(oauth.NewConfigureOAuthCmd())
    33  	cmd.AddCommand(commands.NewConfigureAPIServerNameCmd())
    34  	cmd.AddCommand(commands.NewConfigureAPIServerPortCmd())
    35  
    36  	return cmd
    37  }