cmd

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package cmd provides an execution context for qbec commands and implements process-level lifecycle operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes all the closers for the process and returns an error if any of the closers return an error.

func IsRuntimeError

func IsRuntimeError(err error) bool

IsRuntimeError returns if the supplied error was a runtime error as opposed to an error arising out of user input.

func IsUsageError

func IsUsageError(err error) bool

IsUsageError returns if the supplied error was caused due to incorrect command usage.

func NewContext

func NewContext(root *cobra.Command, opts Options) func() (Context, error)

NewContext sets up the supplied root command with common options and returns a function to get the context after arguments have been parsed.

func NewRuntimeError

func NewRuntimeError(err error) error

NewRuntimeError returns a runtime error

func NewUsageError

func NewUsageError(msg string) error

NewUsageError returns a usage error

func RegisterCleanupTask

func RegisterCleanupTask(closer io.Closer)

RegisterCleanupTask registers an io.Closer for eventual cleanup.

func RegisterSignalHandlers

func RegisterSignalHandlers()

RegisterSignalHandlers registers signal handlers for resource cleanup.

func WrapError

func WrapError(err error) error

WrapError passes through usage errors and wraps all other errors with a runtime marker.

Types

type AppContext

type AppContext struct {
	Context
	// contains filtered or unexported fields
}

AppContext is a context that also has a validated app.

func (AppContext) App

func (c AppContext) App() *model.App

App returns the app set up for this context.

func (AppContext) EnvContext

func (c AppContext) EnvContext(env string) (EnvContext, error)

EnvContext returns an execution context for the specified environment.

type ClientProvider

type ClientProvider func(env string) (KubeClient, error)

ClientProvider returns a kubernetes client for the specific environment

type Context

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

Context is the global context of the qbec command that handles all global options supported by the tool.

func (Context) AppContext

func (c Context) AppContext(app *model.App) (AppContext, error)

AppContext returns an application context for the supplied app. It is valid for the app to be nil for commands that do not need it.

func (Context) AppTag

func (c Context) AppTag() string

AppTag returns the app tag specified

func (Context) BasicEvalContext

func (c Context) BasicEvalContext() (eval.BaseContext, error)

BasicEvalContext returns a basic evaluation context without any app-level machinery.

func (Context) Colorize

func (c Context) Colorize() bool

Colorize returns true if output needs to be colorized.

func (Context) Confirm

func (c Context) Confirm(action string) error

Confirm prompts for confirmation if needed.

func (Context) EnvFiles

func (c Context) EnvFiles() []string

EnvFiles returns additional environment files and URLs

func (Context) EvalConcurrency

func (c Context) EvalConcurrency() int

EvalConcurrency returns the concurrency to be used for evaluating components.

func (Context) ForceOptions

func (c Context) ForceOptions() (ForceOptions, error)

ForceOptions returns the forced context and/ or namespace if any. The caller will never see the value __current__ since that is already resolved by the option processor.

func (Context) KubeContextInfo

func (c Context) KubeContextInfo() (*remote.ContextInfo, error)

KubeContextInfo returns kube context information.

func (Context) ListPageSize added in v0.15.0

func (c Context) ListPageSize() int64

ListPageSize returns the page size for kubernetes list operations

func (Context) RootDir

func (c Context) RootDir() string

RootDir returns an overridden root dir or blank

func (Context) Stderr

func (c Context) Stderr() io.Writer

Stderr returns the standard error configured for the command.

func (Context) Stdout

func (c Context) Stdout() io.Writer

Stdout returns the standard output configured for the command.

func (Context) Verbosity

func (c Context) Verbosity() int

Verbosity returns the log verbosity level

type EnvContext

type EnvContext struct {
	AppContext
	// contains filtered or unexported fields
}

EnvContext is the command context for the intersection of an app and environment

func (EnvContext) Client

func (c EnvContext) Client() (KubeClient, error)

Client returns a kubernetes client for the supplied environment

func (EnvContext) Env

func (c EnvContext) Env() string

Env returns the environment name for this context.

func (EnvContext) EvalContext

func (c EnvContext) EvalContext(cleanMode bool) eval.Context

EvalContext returns the evaluation context for the supplied environment.

func (EnvContext) KubeAttributes

func (c EnvContext) KubeAttributes() (*remote.KubeAttributes, error)

KubeAttributes returns the kubernetes attributes for the supplied environment

func (EnvContext) ObjectProducer

func (c EnvContext) ObjectProducer() eval.LocalObjectProducer

ObjectProducer returns a local object producer for the app and environment.

type ForceOptions

type ForceOptions struct {
	K8sContext   string // override kubernetes context
	K8sNamespace string // override kubernetes default namespace
}

ForceOptions are options that override qbec safety features and disregard configuration in qbec.yaml.

type KubeAttrsProvider

type KubeAttrsProvider func(env string) (*remote.KubeAttributes, error)

KubeAttrsProvider provides k8s attributes of the supplied environment

type KubeClient

KubeClient encapsulates all remote operations needed for the superset of all commands.

type Options

type Options struct {
	Stdout            io.Writer
	Stderr            io.Writer
	SkipConfirm       bool
	ClientProvider    ClientProvider
	KubeAttrsProvider KubeAttrsProvider
}

Options are optional attributes to create a context, mostly used for testing.

Jump to

Keyboard shortcuts

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