runner

package
v0.0.0-...-dc1648f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner controls the SubCommand workflow from end-to-end.

func NewRunner

func NewRunner(cfg *config.Config, subCommand SubCommand) *Runner

NewRunner instantiates a Runner, making sure it's RunE command is mapped to the local method, which executes the whole interface workflow.

func (*Runner) Cmd

func (r *Runner) Cmd() *cobra.Command

Cmd exposes the subcommand's cobra command instance.

func (*Runner) RunE

func (r *Runner) RunE(_ *cobra.Command, args []string) error

RunE cobra's RunE function, executes the whole SubCommand workflow.

type SubCommand

type SubCommand interface {
	// Cmd exposes the SubCommand's cobra command instance.
	Cmd() *cobra.Command

	// Complete should load the required information, arguments, kubernetes resources, etc.
	Complete(_ *config.Config, _ []string) error

	// Validate should validate before "run".
	Validate() error

	// Run performs the primary business logic.
	Run(_ *config.Config) error
}

SubCommand wraps a cobra command with "business" logic, providing a sequence of actions to perform the intended workflow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL