var factory … // SetFactoryForCompletion Store the factory which is needed by the completion functions. // Not all commands have access to the factory, so cannot pass it to the completion functions. func SetFactoryForCompletion(f cmdutil.Factory) { … } // ResourceTypeAndNameCompletionFunc Returns a completion function that completes resource types // and resource names that match the toComplete prefix. It supports the <type>/<name> form. func ResourceTypeAndNameCompletionFunc(f cmdutil.Factory) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // SpecifiedResourceTypeAndNameCompletionFunc Returns a completion function that completes resource // types limited to the specified allowedTypes, and resource names that match the toComplete prefix. // It allows for multiple resources. It supports the <type>/<name> form. func SpecifiedResourceTypeAndNameCompletionFunc(f cmdutil.Factory, allowedTypes []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // SpecifiedResourceTypeAndNameNoRepeatCompletionFunc Returns a completion function that completes resource // types limited to the specified allowedTypes, and resource names that match the toComplete prefix. // It only allows for one resource. It supports the <type>/<name> form. func SpecifiedResourceTypeAndNameNoRepeatCompletionFunc(f cmdutil.Factory, allowedTypes []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // ResourceNameCompletionFunc Returns a completion function that completes as a first argument // the resource names specified by the resourceType parameter, and which match the toComplete prefix. // This function does NOT support the <type>/<name> form: it is meant to be used by commands // that don't support that form. For commands that apply to pods and that support the <type>/<name> // form, please use PodResourceNameCompletionFunc() func ResourceNameCompletionFunc(f cmdutil.Factory, resourceType string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // PodResourceNameCompletionFunc Returns a completion function that completes: // 1- pod names that match the toComplete prefix // 2- resource types containing pods which match the toComplete prefix func PodResourceNameCompletionFunc(f cmdutil.Factory) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // ResourceAndPortCompletionFunc Returns a completion function that completes, as a first argument: // 1- resources that match the toComplete prefix // 2- the ports of the specific resource. i.e: container ports for pod resources and port for services func ResourceAndPortCompletionFunc(f cmdutil.Factory) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // PodResourceNameAndContainerCompletionFunc Returns a completion function that completes, as a first argument: // 1- pod names that match the toComplete prefix // 2- resource types containing pods which match the toComplete prefix // and as a second argument the containers within the specified pod. func PodResourceNameAndContainerCompletionFunc(f cmdutil.Factory) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // ContainerCompletionFunc Returns a completion function that completes the containers within the // pod specified by the first argument. The resource containing the pod can be specified in // the <type>/<name> form. func ContainerCompletionFunc(f cmdutil.Factory) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // ContextCompletionFunc is a completion function that completes as a first argument the // context names that match the toComplete prefix func ContextCompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { … } // ClusterCompletionFunc is a completion function that completes as a first argument the // cluster names that match the toComplete prefix func ClusterCompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { … } // UserCompletionFunc is a completion function that completes as a first argument the // user names that match the toComplete prefix func UserCompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { … } // CompGetResource gets the list of the resource specified which begin with `toComplete`. func CompGetResource(f cmdutil.Factory, resourceName string, toComplete string) []string { … } // CompGetContainers gets the list of containers of the specified pod which begin with `toComplete`. func CompGetContainers(f cmdutil.Factory, podName string, toComplete string) []string { … } // CompGetPodContainerPorts retrieves the list of ports for containers within the specified pod that start with `toComplete`. func CompGetPodContainerPorts(f cmdutil.Factory, podName string, toComplete string) []string { … } // CompGetServicePorts gets the list of ports of the specified service which begin with `toComplete`. func CompGetServicePorts(f cmdutil.Factory, serviceName string, toComplete string) []string { … } // CompGetFromTemplate executes a Get operation using the specified template and args and returns the results // which begin with `toComplete`. func CompGetFromTemplate(template *string, f cmdutil.Factory, namespace string, args []string, toComplete string) []string { … } // ListContextsInConfig returns a list of context names which begin with `toComplete` func ListContextsInConfig(toComplete string) []string { … } // ListClustersInConfig returns a list of cluster names which begin with `toComplete` func ListClustersInConfig(toComplete string) []string { … } // ListUsersInConfig returns a list of user names which begin with `toComplete` func ListUsersInConfig(toComplete string) []string { … } // compGetResourceList returns the list of api resources which begin with `toComplete`. func compGetResourceList(restClientGetter genericclioptions.RESTClientGetter, cmd *cobra.Command, toComplete string) []string { … } // resourceTypeAndNameCompletionFunc Returns a completion function that completes resource types // and resource names that match the toComplete prefix. It supports the <type>/<name> form. func resourceTypeAndNameCompletionFunc(f cmdutil.Factory, allowedTypes []string, allowRepeat bool) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) { … } // doPodResourceCompletion Returns completions of: // 1- pod names that match the toComplete prefix // 2- resource types containing pods which match the toComplete prefix func doPodResourceCompletion(f cmdutil.Factory, toComplete string) ([]string, cobra.ShellCompDirective) { … } // convertResourceNameToPodName Converts a resource name to a pod name. // If the resource name is of the form <type>/<name>, we use // polymorphichelpers.AttachablePodForObjectFn(), if not, the resource name // is already a pod name. func convertResourceNameToPodName(f cmdutil.Factory, resourceName string) string { … }