github.com/verrazzano/verrazzano@v1.7.0/tools/psr/psrctl/cmd/root/root.go (about)

     1  // Copyright (c) 2022, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package root
     5  
     6  import (
     7  	"github.com/spf13/cobra"
     8  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/explain"
     9  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/list"
    10  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/start"
    11  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/stop"
    12  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/update"
    13  	"github.com/verrazzano/verrazzano/tools/psr/psrctl/cmd/version"
    14  	cmdhelpers "github.com/verrazzano/verrazzano/tools/vz/cmd/helpers"
    15  	"github.com/verrazzano/verrazzano/tools/vz/pkg/helpers"
    16  )
    17  
    18  const (
    19  	CommandName = "psrctl"
    20  	helpShort   = "The psrctl tool runs PSR scenarios in a Verrazzano environment"
    21  	helpLong    = `The psrctl tool runs PSR scenarios in a Verrazzano environment.  
    22  A scenario consists of a set of use cases, where the use cases run in parallel, independent from each other.
    23  Each use case is installed as a single Helm release.
    24  	
    25  A use case is a specific type of work executing in a pod or set of pods. Some examples of use cases are: 
    26  post log records to OpenSearch, scale OpenSearch, upgrade Verrazzano, randomly terminate MySQL pods, etc.  
    27  Use cases are executed in the context of a worker doing work in a pod running in a continuous loop.  
    28  Workers execute single task only (the use case).  Workers can be scaled out vertically (multiple threads) 
    29  and horizontally (multiple replicas).  There are a few configuration tuning parameters that control the execution, 
    30  such as time to sleep between loop iterations, the number of loop iterations, etc.
    31  	
    32  All scenario and use case configuration is controlled by YAML files that are compiled into the psrctl image.`
    33  )
    34  
    35  // NewRootCmd - create the root cobra command
    36  func NewRootCmd(vzHelper helpers.VZHelper) *cobra.Command {
    37  	cmd := cmdhelpers.NewCommand(vzHelper, CommandName, helpShort, helpLong)
    38  
    39  	// Add commands
    40  	cmd.AddCommand(explain.NewCmdExplain(vzHelper))
    41  	cmd.AddCommand(list.NewCmdList(vzHelper))
    42  	cmd.AddCommand(start.NewCmdStart(vzHelper))
    43  	cmd.AddCommand(stop.NewCmdStop(vzHelper))
    44  	cmd.AddCommand(update.NewCmdUpdate(vzHelper))
    45  	cmd.AddCommand(version.NewCmdVersion(vzHelper))
    46  
    47  	return cmd
    48  }