Documentation
¶
Index ¶
- Constants
- func AddOutputFlag(cmd *cobra.Command, defaultFmt string, formats ...string)
- func CompleteNamespaces(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellCompDirective)
- func CompleteOutputFormats(formats ...string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func CompleteResourceNames(cmd *cobra.Command, gvr schema.GroupVersionResource, ...) ([]string, cobra.ShellCompDirective)
- func ExecInPod(config *rest.Config, kubeCl kubernetes.Interface, cmdLine []string, ...) (remotecommand.Executor, error)
- func FilterByPrefix(values []string, toComplete string) []string
- func GetDeckhousePod(kubeCl kubernetes.Interface) (string, error)
- func NewDynamicClient(cmd *cobra.Command) (dynamic.Interface, error)
- func PrintObject(w io.Writer, obj *unstructured.Unstructured, format string) error
- func SetupK8sClientSet(kubeconfigPath, contextName string) (*rest.Config, *kubernetes.Clientset, error)
Constants ¶
const DefaultKubeContext = ""
Variables ¶
This section is empty.
Functions ¶
func AddOutputFlag ¶ added in v0.29.32
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
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 FilterByPrefix ¶ added in v0.29.32
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
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.