commands

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

package commands contains Cobra commands that implement the CLI behavior. The commands are responsible for arguments and flags manipulation/validation, printing of success and error, etc. Commands delegate to a high level client for actual interaction with the kubernetes environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgValidationConjunction

func ArgValidationConjunction(validators ...cobra.PositionalArgs) cobra.PositionalArgs

ArgValidationConjunction returns a PositionalArgs validator that checks all provided validators in turn (all must pass).

func AtPosition

func AtPosition(i int, validator PositionalArg) cobra.PositionalArgs

AtPosition returns a PositionalArgs that applies the single valued validator to the i-th argument. The actual number of arguments is not checked by this function (use cobra's MinimumNArgs, ExactArgs, etc)

func Channel

func Channel() *cobra.Command

func ChannelCreate

func ChannelCreate(fcTool *core.Client) *cobra.Command

func ChannelDelete

func ChannelDelete(fcTool *core.Client) *cobra.Command

func ChannelList

func ChannelList(fcTool *core.Client) *cobra.Command

func Completion added in v0.1.3

func Completion(rootCmd *cobra.Command) *cobra.Command

func CreateAndWireRootCommand

func CreateAndWireRootCommand(manifests map[string]*core.Manifest, localBuilder string, defaultRunImage string) *cobra.Command

func Display added in v0.2.0

func Display(out io.Writer, items []interface{}, extractors []NamedExtractor)

func Docs

func Docs(rootCmd *cobra.Command, fs Filesystem) *cobra.Command

func FindSubcommand added in v0.2.0

func FindSubcommand(command *cobra.Command, names ...string) *cobra.Command

func Function

func Function() *cobra.Command

func FunctionCreate

func FunctionCreate(fcTool *core.Client, defaults FunctionCreateDefaults) *cobra.Command

func FunctionUpdate added in v0.2.0

func FunctionUpdate(fcTool *core.Client) *cobra.Command

func GenerateDocs added in v0.2.0

func GenerateDocs(rootCommand *cobra.Command, directory string, fs Filesystem) error

func LabelArgs

func LabelArgs(cmd *cobra.Command, labels ...string)

func Namespace

func Namespace() *cobra.Command

func NamespaceInit

func NamespaceInit(manifests map[string]*core.Manifest, kc *core.KubectlClient) *cobra.Command

func OptionalAtPosition added in v0.1.3

func OptionalAtPosition(i int, validator PositionalArg) cobra.PositionalArgs

func PrintInterruptedCompletion added in v0.1.3

func PrintInterruptedCompletion(cmd *cobra.Command)

func PrintSuccessfulCompletion added in v0.1.3

func PrintSuccessfulCompletion(cmd *cobra.Command)

func Service

func Service() *cobra.Command

func ServiceCreate

func ServiceCreate(fcTool *core.Client) *cobra.Command

func ServiceDelete

func ServiceDelete(fcClient *core.Client) *cobra.Command

func ServiceInvoke

func ServiceInvoke(fcClient *core.Client) *cobra.Command

func ServiceList

func ServiceList(fcClient *core.Client) *cobra.Command

func ServiceStatus

func ServiceStatus(fcClient *core.Client) *cobra.Command

func ServiceUpdate added in v0.2.0

func ServiceUpdate(client *core.Client) *cobra.Command

func Subscription added in v0.1.3

func Subscription() *Command

func SubscriptionCreate added in v0.1.3

func SubscriptionCreate(client *core.Client) *Command

func SubscriptionDelete added in v0.1.3

func SubscriptionDelete(client *core.Client) *Command

func SubscriptionList added in v0.1.3

func SubscriptionList(client *core.Client) *Command

func System

func System() *cobra.Command

func SystemInstall

func SystemInstall(manifests map[string]*core.Manifest, kc *core.KubectlClient) *cobra.Command

func SystemUninstall added in v0.1.1

func SystemUninstall(kc *core.KubectlClient) *cobra.Command

func UpToDashDash added in v0.1.1

func UpToDashDash(delegate cobra.PositionalArgs) cobra.PositionalArgs

UpToDashDash returns a validator that will invoke the `delegate` validator, but only with args before the splitting `--`, if any

func Version

func Version() *cobra.Command

func Visit

func Visit(cmd *cobra.Command, f func(c *cobra.Command) error) error

Visit applies the provided function f to the given command and its children, depth first. Exits as soon as an error occurs.

Types

type CobraEFunction

type CobraEFunction func(cmd *cobra.Command, args []string) error

CobraEFunction is the type of functions cobra expects for Run, PreRun, etc that can return an error.

func FlagsValidatorAsCobraRunE

func FlagsValidatorAsCobraRunE(validator FlagsValidator) CobraEFunction

FlagsValidatorAsCobraRunE allows a FlagsValidator to be used as a CobraEFunction (typically PreRunE())

type Filesystem added in v0.2.0

type Filesystem interface {
	MkdirAll(name string, perm os.FileMode) error
}

type FlagsMatcher

type FlagsMatcher interface {
	Evaluate(command *cobra.Command) bool
	Description() string
}

func Set

func Set(name string) FlagsMatcher

type FlagsValidator

type FlagsValidator func(cmd *cobra.Command) error

func AtLeastOneOf

func AtLeastOneOf(flagNames ...string) FlagsValidator

AtLeastOneOf returns a FlagsValidator that asserts that at least one of the passed in flags is set.

func AtMostOneOf

func AtMostOneOf(flagNames ...string) FlagsValidator

AtMostOneOf returns a FlagsValidator that asserts that at most one of the passed in flags is set.

func ExactlyOneOf added in v0.1.3

func ExactlyOneOf(flagNames ...string) FlagsValidator

ExactlyOneOf returns a FlagsValidator that asserts that one and only one of the passed in flags is set.

func FlagsDependency

func FlagsDependency(matcher FlagsMatcher, delegate FlagsValidator) FlagsValidator

FlagsDependency returns a validator that will evaluate the given delegate if the provided flag matcher returns true. Use to enforce scenarios such as "if --foo is set, then --bar must be set as well".

func FlagsValidationConjunction

func FlagsValidationConjunction(validators ...FlagsValidator) FlagsValidator

FlagsValidationConjunction returns a FlagsValidator validator that checks all provided validators in turn (all must pass).

func NotBlank added in v0.1.3

func NotBlank(flagName string) FlagsValidator

NotBlank returns a FlagsValidator that asserts that the given flag is not made entirely of space characters.

type FunctionCreateDefaults added in v0.2.0

type FunctionCreateDefaults struct {
	LocalBuilder    string // the image for the builder used when building locally
	DefaultRunImage string // the default for the --run-image flag.
}

FunctionCreateDefaults contains values for "defaults" or "constants" that can be overridden depending on the actual CLI tool being built.

type LocalFs added in v0.2.0

type LocalFs struct{}

func (LocalFs) MkdirAll added in v0.2.0

func (LocalFs) MkdirAll(name string, perm os.FileMode) error

type Marshaller

type Marshaller interface {
	Marshal(o interface{}) error
}

func NewMarshaller

func NewMarshaller(w io.Writer) Marshaller

type NamedExtractor added in v0.2.0

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

type PositionalArg

type PositionalArg func(cmd *cobra.Command, arg string) error

PositionalArg is a function for validating a single argument

func KubernetesValidation

func KubernetesValidation(k8s func(string) []string) PositionalArg

KubernetesValidation turns a kubernetes-style validation function into a PositionalArg

func ValidName

func ValidName() PositionalArg

type StringExtractor added in v0.2.0

type StringExtractor func(interface{}) string

Jump to

Keyboard shortcuts

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