Documentation ¶
Overview ¶
Package cmd provides an execution context for qbec commands and implements process-level lifecycle operations.
Index ¶
- func Close() error
- func IsRuntimeError(err error) bool
- func IsUsageError(err error) bool
- func NewContext(root *cobra.Command, opts Options) func() (Context, error)
- func NewRuntimeError(err error) error
- func NewUsageError(msg string) error
- func RegisterCleanupTask(closer io.Closer)
- func RegisterSignalHandlers()
- func WrapError(err error) error
- type AppContext
- type ClientProvider
- type Context
- func (c Context) AppContext(app *model.App) (AppContext, error)
- func (c Context) AppTag() string
- func (c Context) BasicEvalContext() (eval.BaseContext, error)
- func (c Context) Colorize() bool
- func (c Context) Confirm(action string) error
- func (c Context) EnvFiles() []string
- func (c Context) EvalConcurrency() int
- func (c Context) ForceOptions() (ForceOptions, error)
- func (c Context) KubeContextInfo() (*remote.ContextInfo, error)
- func (c Context) ListPageSize() int64
- func (c Context) RootDir() string
- func (c Context) Stderr() io.Writer
- func (c Context) Stdout() io.Writer
- func (c Context) Verbosity() int
- type EnvContext
- type ForceOptions
- type KubeAttrsProvider
- type KubeClient
- type Options
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 ¶
IsRuntimeError returns if the supplied error was a runtime error as opposed to an error arising out of user input.
func IsUsageError ¶
IsUsageError returns if the supplied error was caused due to incorrect command usage.
func NewContext ¶
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 ¶
NewRuntimeError returns a runtime error
func RegisterCleanupTask ¶
RegisterCleanupTask registers an io.Closer for eventual cleanup.
func RegisterSignalHandlers ¶
func RegisterSignalHandlers()
RegisterSignalHandlers registers signal handlers for resource cleanup.
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) BasicEvalContext ¶
func (c Context) BasicEvalContext() (eval.BaseContext, error)
BasicEvalContext returns a basic evaluation context without any app-level machinery.
func (Context) EvalConcurrency ¶
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
ListPageSize returns the page size for kubernetes list operations
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 ¶
type KubeClient interface { DisplayName(o model.K8sMeta) string IsNamespaced(kind schema.GroupVersionKind) (bool, error) Get(ctx context.Context, obj model.K8sMeta) (*unstructured.Unstructured, error) Sync(ctx context.Context, obj model.K8sLocalObject, opts remote.SyncOptions) (*remote.SyncResult, error) ValidatorFor(ctx context.Context, gvk schema.GroupVersionKind) (k8smeta.Validator, error) ListObjects(ctx context.Context, scope remote.ListQueryConfig) (remote.Collection, error) Delete(context.Context, model.K8sMeta, remote.DeleteOptions) (*remote.SyncResult, error) ObjectKey(obj model.K8sMeta) string ResourceInterface(obj schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error) }
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.