cmd

package
v0.0.0-...-55ce2e8 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cmd holds the root command and all sub-commands, wiring them up together. This package also implements kubectl/oc component workflow via SubCommand interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmdSHP

func NewCmdSHP(ioStreams genericclioptions.IOStreams) *cobra.Command

NewCmdSHP create a new SHP root command, linking together all sub-commands organized by groups.

Types

type Options

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

Options global options informed to the command-line, includes generic kubectl flags. This should contain all information needed for instantiating a API client.

func NewOptions

func NewOptions() *Options

NewOptions instantiate options and kubectl generic flags.

func (*Options) AddFlags

func (o *Options) AddFlags(flags *pflag.FlagSet)

AddFlags register global flags.

func (*Options) Factory

func (o *Options) Factory() kcmdutil.Factory

Factory exposes the kubectl's Factory to instantiate API clients and interact with configuration.

type Runner

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

Runner execute the sub-command lifecycle, wrapper around sub-commands.

func NewRunner

func NewRunner(opts *Options, ioStreams genericclioptions.IOStreams, subCmd SubCommand) *Runner

NewRunner instantiate a Runner.

func (*Runner) Cmd

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

Cmd is a wrapper around sub-command's Cobra, it wires up global flags and set a single RunE executor to self.

func (*Runner) RunE

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

RunE cobra.Command's RunE implementation focusing on sub-commands lifecycle. To achieve it, a dynamic client and configured namespace are informed.

type SubCommand

type SubCommand interface {
	// Cmd shares the cobra.Command instance.
	Cmd() *cobra.Command
	// Complete aggregate data needed for the sub-command primary logic.
	Complete(client dynamic.Interface, ns string, args []string) error
	// Validate perform validation against the context collected.
	Validate() error
	// Run execute the primary sub-command logic.
	Run(client dynamic.Interface, ns string) error
}

SubCommand defines the methods for a sub-command wrapped with Runner.

Jump to

Keyboard shortcuts

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