cmd

package
v0.0.0-...-45e1237 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package cmd wires the Karta CLI Cobra command tree.

Index

Constants

View Source
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

View Source
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

func NewRootCommand() *cobra.Command

NewRootCommand builds the root command for the kli binary. Global flags are registered as persistent flags so every subcommand inherits them.

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

func NewEnum[T ~string](typeName string, def T, allowed ...T) *Enum[T]

NewEnum returns an Enum seeded with def and constrained to allowed. typeName is shown for the flag's value in help/usage.

func NewOutputFlag

func NewOutputFlag(supportsWide bool) *Enum[generator.Output]

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.

func (*Enum[T]) Allowed

func (e *Enum[T]) Allowed() []string

Allowed returns the permitted values as strings, for usage text and shell completion.

func (*Enum[T]) Get

func (e *Enum[T]) Get() T

Get returns the current typed value.

func (*Enum[T]) Set

func (e *Enum[T]) Set(v string) error

func (*Enum[T]) String

func (e *Enum[T]) String() string

func (*Enum[T]) Type

func (e *Enum[T]) Type() string

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

func NewEnumSlice[T ~string](typeName string, allowed ...T) *EnumSlice[T]

NewEnumSlice returns an empty EnumSlice constrained to allowed. typeName is shown for the flag's value in help/usage.

func NewPhaseFlag

func NewPhaseFlag() *EnumSlice[string]

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

func (e *EnumSlice[T]) Allowed() []string

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.

func (*EnumSlice[T]) Set

func (e *EnumSlice[T]) Set(v string) error

func (*EnumSlice[T]) String

func (e *EnumSlice[T]) String() string

String is empty for no values, which is how pflag knows not to print a default.

func (*EnumSlice[T]) Type

func (e *EnumSlice[T]) Type() string

Directories

Path Synopsis
Command kli is the Karta CLI: workload-aware visibility for any Kubernetes workload type.
Command kli is the Karta CLI: workload-aware visibility for any Kubernetes workload type.

Jump to

Keyboard shortcuts

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