cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameArgumentName  = "name"
	NamesArgumentName = "name(s)"
)
View Source
const (
	TailSinceCreateDefault = time.Minute
	TailSinceDefault       = time.Second
)
View Source
const (
	AllFlagName                   = "--all"
	AllNamespacesFlagName         = "--all-namespaces"
	ApplicationRefFlagName        = "--application-ref"
	ArtifactFlagName              = "--artifact"
	BootstrapServersFlagName      = "--bootstrap-servers"
	CacheSizeFlagName             = "--cache-size"
	ContainerConcurrencyFlagName  = "--container-concurrency"
	ConfigFlagName                = "--config"
	ConfigurationRefFlagName      = "--configuration-ref"
	ContainerRefFlagName          = "--container-ref"
	ContentTypeFlagName           = "--content-type"
	DefaultImagePrefixFlagName    = "--default-image-prefix"
	DirectoryFlagName             = "--directory"
	DockerHubFlagName             = "--docker-hub"
	DryRunFlagName                = "--dry-run"
	EnvFlagName                   = "--env"
	EnvFromFlagName               = "--env-from"
	FunctionRefFlagName           = "--function-ref"
	GatewayFlagName               = "--gateway"
	GcrFlagName                   = "--gcr"
	GitRepoFlagName               = "--git-repo"
	GitRevisionFlagName           = "--git-revision"
	HandlerFlagName               = "--handler"
	ImageFlagName                 = "--image"
	IngressPolicyFlagName         = "--ingress-policy"
	InputFlagName                 = "--input"
	InvokerFlagName               = "--invoker"
	KubeConfigFlagName            = "--kubeconfig"
	KubeConfigFlagNameDeprecated  = "--kube-config"
	LimitCPUFlagName              = "--limit-cpu"
	LimitMemoryFlagName           = "--limit-memory"
	LocalPathFlagName             = "--local-path"
	MaxScaleFlagName              = "--max-scale"
	MinScaleFlagName              = "--min-scale"
	NamespaceFlagName             = "--namespace"
	NoColorFlagName               = "--no-color"
	OutputFlagName                = "--output"
	RegistryFlagName              = "--registry"
	RegistryUserFlagName          = "--registry-user"
	ServiceRefFlagName            = "--service-ref"
	ServiceURLFlagName            = "--service-url"
	SetDefaultImagePrefixFlagName = "--set-default-image-prefix"
	ShellFlagName                 = "--shell"
	SinceFlagName                 = "--since"
	SubPathFlagName               = "--sub-path"
	TailFlagName                  = "--tail"
	TargetPortFlagName            = "--target-port"
	WaitTimeoutFlagName           = "--wait-timeout"
)
View Source
const (
	CoreRuntime      = "core"
	StreamingRuntime = "streaming"
	KnativeRuntime   = "knative"
)
View Source
const CurrentField = validation.CurrentField

Variables

View Source
var (
	FaintColor   = color.New(color.Faint)
	InfoColor    = color.New(color.FgCyan)
	SuccessColor = color.New(color.FgGreen)
	WarnColor    = color.New(color.FgYellow)
	ErrorColor   = color.New(color.FgRed)
)
View Source
var (
	ErrDisallowedFields  = validation.ErrDisallowedFields
	ErrInvalidArrayValue = validation.ErrInvalidArrayValue
	ErrInvalidValue      = validation.ErrInvalidValue
	ErrMissingField      = validation.ErrMissingField
	ErrMissingOneOf      = validation.ErrMissingOneOf
	ErrMultipleOneOf     = validation.ErrMultipleOneOf
)
View Source
var ErrIgnoreArg = fmt.Errorf("ignore argument")
View Source
var SilentError = &silentError{}

Functions

func AllNamespacesFlag

func AllNamespacesFlag(cmd *cobra.Command, c *Config, namespace *string, allNamespaces *bool)

func Args

func Args(cmd *cobra.Command, argDefs ...Arg)

func CommandFromContext

func CommandFromContext(ctx context.Context) *cobra.Command

func DryRunResource

func DryRunResource(ctx context.Context, resource runtime.Object, gvk schema.GroupVersionKind)

func ExecOptions

func ExecOptions(ctx context.Context, c *Config, opts Executable) func(cmd *cobra.Command, args []string) error

ExecOptions bridges a cobra RunE function to the Executable interface. All flags and arguments must already be bound, with explicit or default values, to the options struct being validated. This function is typically used to define the RunE phase of a command.

```

cmd := &cobra.Command{
	   ...
	   RunE: cli.ExecOptions(c, opts),
}

```

func FormatArgs

func FormatArgs(cmd *cobra.Command) string

func FormatConditionStatus

func FormatConditionStatus(cond *apis.Condition) string

func FormatEmptyString

func FormatEmptyString(str string) string

func FormatTimestampSince

func FormatTimestampSince(timestamp metav1.Time, now time.Time) string

func NamespaceFlag

func NamespaceFlag(cmd *cobra.Command, c *Config, namespace *string)

func PrintResourceStatus

func PrintResourceStatus(c *Config, name string, condition *apis.Condition)

func ReadStdin

func ReadStdin(c *Config, value *[]byte, prompt string) func(*cobra.Command, []string) error

func Sequence

func Sequence(items ...func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) error

func Serrorf

func Serrorf(format string, a ...interface{}) string

func Sfaintf

func Sfaintf(format string, a ...interface{}) string

func SilenceError

func SilenceError(err error) error

func Sinfof

func Sinfof(format string, a ...interface{}) string

func SortByNamespaceAndName

func SortByNamespaceAndName(s interface{})

func Ssuccessf

func Ssuccessf(format string, a ...interface{}) string

func StripDash

func StripDash(flagName string) string

func Swarnf

func Swarnf(format string, a ...interface{}) string

func ValidateOptions

func ValidateOptions(ctx context.Context, opts Validatable) func(cmd *cobra.Command, args []string) error

ValidateOptions bridges a cobra RunE function to the Validatable interface. All flags and arguments must already be bound, with explicit or default values, to the options struct being validated. This function is typically used to define the PreRunE phase of a command.

```

cmd := &cobra.Command{
	   ...
	   PreRunE: cli.ValidateOptions(opts),
}

```

func Visit

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

func WithCommand

func WithCommand(ctx context.Context, cmd *cobra.Command) context.Context

Types

type Arg

type Arg struct {
	Name     string
	Arity    int
	Optional bool
	Set      func(cmd *cobra.Command, args []string, offset int) error
}

func BareDoubleDashArgs

func BareDoubleDashArgs(values *[]string) Arg

func NameArg

func NameArg(name *string) Arg

func NamesArg

func NamesArg(names *[]string) Arg

type CompiledEnv

type CompiledEnv struct {
	Name     string
	Version  string
	GitSha   string
	GitDirty bool
	Runtimes map[string]bool
}

type Config

type Config struct {
	CompiledEnv
	ViperConfigFile string
	KubeConfigFile  string
	k8s.Client
	Exec   func(ctx context.Context, command string, args ...string) *exec.Cmd
	Pack   pack.Client
	Kail   kail.Logger
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

func Initialize

func Initialize() *Config

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) Eerrorf

func (c *Config) Eerrorf(format string, a ...interface{}) (n int, err error)

func (*Config) Einfof

func (c *Config) Einfof(format string, a ...interface{}) (n int, err error)

func (*Config) Eprintf

func (c *Config) Eprintf(format string, a ...interface{}) (n int, err error)

func (*Config) Errorf

func (c *Config) Errorf(format string, a ...interface{}) (n int, err error)

func (*Config) Esuccessf

func (c *Config) Esuccessf(format string, a ...interface{}) (n int, err error)

func (*Config) Infof

func (c *Config) Infof(format string, a ...interface{}) (n int, err error)

func (*Config) Printf

func (c *Config) Printf(format string, a ...interface{}) (n int, err error)

func (*Config) Successf

func (c *Config) Successf(format string, a ...interface{}) (n int, err error)

type DryRunable

type DryRunable interface {
	IsDryRun() bool
}

type Executable

type Executable interface {
	Exec(ctx context.Context, c *Config) error
}

type FieldErrors added in v0.5.0

type FieldErrors = validation.FieldErrors

type Validatable

type Validatable = validation.Validatable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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