utilk8s

package
v0.29.32 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultKubeContext = ""

Variables

This section is empty.

Functions

func AddOutputFlag added in v0.29.32

func AddOutputFlag(cmd *cobra.Command, defaultFmt string, formats ...string)

AddOutputFlag declares the standard "-o/--output" flag and its completion in a single line. Default value and accepted formats are command-specific so callers list them explicitly.

func CompleteNamespaces added in v0.29.32

func CompleteNamespaces(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteNamespaces returns namespace names for shell completion.

func CompleteOutputFormats added in v0.29.32

func CompleteOutputFormats(formats ...string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

CompleteOutputFormats returns a cobra completion function that suggests a static list of output format names (e.g. "table", "json", "yaml") filtered by the current toComplete prefix. The returned function is safe to pass directly to cmd.RegisterFlagCompletionFunc.

func CompleteResourceNames added in v0.29.32

func CompleteResourceNames(cmd *cobra.Command, gvr schema.GroupVersionResource, namespace, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteResourceNames lists names of objects of the given GVR for shell completion. Pass namespace="" for cluster-scoped resources or to list across every namespace for namespaced resources; pass a concrete namespace to restrict the listing to that namespace.

Returns ShellCompDirectiveError if the cluster is unreachable; cobra renders that as "no completions" in the shell rather than failing the command.

func ExecInPod added in v0.12.0

func ExecInPod(config *rest.Config, kubeCl kubernetes.Interface, cmdLine []string, podName string, namespace string, containerName string) (remotecommand.Executor, error)

func FilterByPrefix added in v0.29.32

func FilterByPrefix(values []string, toComplete string) []string

FilterByPrefix returns elements of values that start with toComplete. Convenient for static enum completions.

func GetDeckhousePod added in v0.12.0

func GetDeckhousePod(kubeCl kubernetes.Interface) (string, error)

func NewDynamicClient added in v0.29.32

func NewDynamicClient(cmd *cobra.Command) (dynamic.Interface, error)

NewDynamicClient creates a dynamic Kubernetes client from cobra command flags. It reads "kubeconfig" and "context" persistent flags registered on a parent command.

func PrintObject added in v0.29.32

func PrintObject(w io.Writer, obj *unstructured.Unstructured, format string) error

PrintObject writes an unstructured Kubernetes object to w in the given format. Supported formats: "json", "yaml"; anything else prints Kind/Name.

func SetupK8sClientSet

func SetupK8sClientSet(kubeconfigPath, contextName string) (*rest.Config, *kubernetes.Clientset, error)

SetupK8sClientSet reads kubeconfig file at kubeconfigPath and constructs a kubernetes clientset from it. If contextName is not empty, context under that name is used instead of default.

Types

This section is empty.

Jump to

Keyboard shortcuts

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