Documentation
¶
Overview ¶
Package cmd wires the Karta CLI Cobra command tree.
Index ¶
Constants ¶
const ( ExitError = 1 // cluster unreachable, auth failure ExitUsage = 2 // invalid flag value or argument ExitWorkloadNotFound = 3 // no such workload of the requested type ExitNotFound = 4 // no Karta definition covers the requested type )
Exit codes. The numbers are not a contract; only that conditions differ.
Variables ¶
var ErrInvalidValue = errors.New("invalid value")
ErrInvalidValue is wrapped by Enum.Set when a value is not one of the allowed set, so callers can match it with errors.Is.
Functions ¶
func NewRootCommand ¶
NewRootCommand builds the root command for the kli binary. Global flags are registered as persistent flags so every subcommand inherits them.
func RESTConfig ¶
func RESTConfig(rcg genericclioptions.RESTClientGetter) (*rest.Config, error)
func ResolvedNamespace ¶
func ResolvedNamespace(rcg genericclioptions.RESTClientGetter) (string, bool, error)
Types ¶
type Config ¶
type Config struct {
Output string `mapstructure:"output" yaml:"output" json:"output"`
}
type Enum ¶
type Enum[T ~string] struct { // contains filtered or unexported fields }
Enum backs a --flag whose value must be one of a fixed set. It implements pflag.Value and works with any ~string type.
func NewEnum ¶
NewEnum returns an Enum seeded with def and constrained to allowed. typeName is shown for the flag's value in help/usage.
func NewOutputFlag ¶
NewOutputFlag returns an Enum backing the -o/--output flag, defaulting to table. A command rendering no extra columns leaves wide out, so the flag rejects it at parse time rather than the command rejecting it later.
type EnumSlice ¶
type EnumSlice[T ~string] struct { // contains filtered or unexported fields }
EnumSlice backs a repeatable --flag constrained to a fixed set. Values accumulate across occurrences, and one occurrence may carry a comma list.
func NewEnumSlice ¶
NewEnumSlice returns an empty EnumSlice constrained to allowed. typeName is shown for the flag's value in help/usage.
func NewPhaseFlag ¶
NewPhaseFlag returns an EnumSlice backing the --phase flag. Entries() omits Undefined, which a workload without a status mapping still resolves to.
func (*EnumSlice[T]) Allowed ¶
Allowed returns the permitted values as strings, for usage text and shell completion.
func (*EnumSlice[T]) Get ¶
func (e *EnumSlice[T]) Get() []T
Get returns the values collected so far.