shared

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControllerFromCmd

func ControllerFromCmd(cmd *cobra.Command) (*controller.Exec, error)

ControllerFromCmd reuses the controller helper from create/shared.

func ExplicitFlag added in v0.2.0

func ExplicitFlag(cmd *cobra.Command, flagName, viperKey string) string

ExplicitFlag returns the flag's value only when the user explicitly provided it. This avoids viper.SetDefault side-effects leaking hardcoded defaults (e.g. "default") into list-operation filters, where an unset flag must mean "no filter".

func FormatControllers added in v0.4.0

func FormatControllers(controllers []string) string

FormatControllers renders a Status.SubtreeControllers slice for the CONTROLLERS table column emitted by `kuke get <kind> --show-controllers` (issue #328). Empty input renders as "-" so the column never collapses to an unaligned blank cell.

func LoggerFromCmd

func LoggerFromCmd(cmd *cobra.Command) (*slog.Logger, error)

LoggerFromCmd reuses the logger helper from create/shared.

func PrintJSON

func PrintJSON(doc interface{}) error

PrintJSON prints the resource as JSON.

func PrintTable

func PrintTable(cmd *cobra.Command, headers []string, rows [][]string)

PrintTable prints resources in a table format.

func PrintYAML

func PrintYAML(doc interface{}) error

PrintYAML prints the resource as YAML.

Types

type OutputFormat

type OutputFormat string

OutputFormat represents the output format type.

const (
	OutputFormatYAML  OutputFormat = "yaml"
	OutputFormatJSON  OutputFormat = "json"
	OutputFormatTable OutputFormat = "table"
)

func ParseOutputFormat

func ParseOutputFormat(cmd *cobra.Command) (OutputFormat, error)

ParseOutputFormat resolves the output format using kuke's standard precedence: explicit `--output`/`-o` flag > KUKEON_GET_OUTPUT env (and any other source viper has bound to `kuke/get/output`) > table default. Each `kuke get <kind>` subcommand binds its own `--output` flag to the shared viper key at construction time, but viper only retains the last binding for a given key; reading the active command's flag directly keeps the flag working for every subcommand and lets viper handle the env/config fall-throughs.

Jump to

Keyboard shortcuts

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