mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Update bashcompletion codes for kubectl patch
This commit is contained in:
parent
5cc540fec1
commit
910b6bce33
@ -313,7 +313,7 @@ __kubectl_require_pod_and_container()
|
||||
|
||||
__custom_func() {
|
||||
case ${last_command} in
|
||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop)
|
||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop | kubectl_edit | kubectl_patch)
|
||||
__kubectl_get_resource
|
||||
return
|
||||
;;
|
||||
@ -1144,7 +1144,74 @@ _kubectl_patch()
|
||||
must_have_one_flag+=("--patch=")
|
||||
must_have_one_flag+=("-p")
|
||||
must_have_one_noun=()
|
||||
must_have_one_noun+=("componentstatus")
|
||||
must_have_one_noun+=("configmap")
|
||||
must_have_one_noun+=("daemonset")
|
||||
must_have_one_noun+=("deployment")
|
||||
must_have_one_noun+=("endpoints")
|
||||
must_have_one_noun+=("event")
|
||||
must_have_one_noun+=("horizontalpodautoscaler")
|
||||
must_have_one_noun+=("ingress")
|
||||
must_have_one_noun+=("job")
|
||||
must_have_one_noun+=("limitrange")
|
||||
must_have_one_noun+=("namespace")
|
||||
must_have_one_noun+=("node")
|
||||
must_have_one_noun+=("persistentvolume")
|
||||
must_have_one_noun+=("persistentvolumeclaim")
|
||||
must_have_one_noun+=("pod")
|
||||
must_have_one_noun+=("podsecuritypolicy")
|
||||
must_have_one_noun+=("podtemplate")
|
||||
must_have_one_noun+=("replicaset")
|
||||
must_have_one_noun+=("replicationcontroller")
|
||||
must_have_one_noun+=("resourcequota")
|
||||
must_have_one_noun+=("secret")
|
||||
must_have_one_noun+=("service")
|
||||
must_have_one_noun+=("serviceaccount")
|
||||
must_have_one_noun+=("thirdpartyresource")
|
||||
must_have_one_noun+=("thirdpartyresourcedata")
|
||||
noun_aliases=()
|
||||
noun_aliases+=("componentstatuses")
|
||||
noun_aliases+=("configmaps")
|
||||
noun_aliases+=("cs")
|
||||
noun_aliases+=("daemonsets")
|
||||
noun_aliases+=("deployments")
|
||||
noun_aliases+=("ds")
|
||||
noun_aliases+=("endpoints")
|
||||
noun_aliases+=("ep")
|
||||
noun_aliases+=("ev")
|
||||
noun_aliases+=("events")
|
||||
noun_aliases+=("horizontalpodautoscalers")
|
||||
noun_aliases+=("hpa")
|
||||
noun_aliases+=("ing")
|
||||
noun_aliases+=("ingresses")
|
||||
noun_aliases+=("jobs")
|
||||
noun_aliases+=("limitranges")
|
||||
noun_aliases+=("limits")
|
||||
noun_aliases+=("namespaces")
|
||||
noun_aliases+=("no")
|
||||
noun_aliases+=("nodes")
|
||||
noun_aliases+=("ns")
|
||||
noun_aliases+=("persistentvolumeclaims")
|
||||
noun_aliases+=("persistentvolumes")
|
||||
noun_aliases+=("po")
|
||||
noun_aliases+=("pods")
|
||||
noun_aliases+=("podsecuritypolicies")
|
||||
noun_aliases+=("podtemplates")
|
||||
noun_aliases+=("pv")
|
||||
noun_aliases+=("pvc")
|
||||
noun_aliases+=("quota")
|
||||
noun_aliases+=("rc")
|
||||
noun_aliases+=("replicasets")
|
||||
noun_aliases+=("replicationcontrollers")
|
||||
noun_aliases+=("resourcequotas")
|
||||
noun_aliases+=("rs")
|
||||
noun_aliases+=("sa")
|
||||
noun_aliases+=("secrets")
|
||||
noun_aliases+=("serviceaccounts")
|
||||
noun_aliases+=("services")
|
||||
noun_aliases+=("svc")
|
||||
noun_aliases+=("thirdpartyresourcedatas")
|
||||
noun_aliases+=("thirdpartyresources")
|
||||
}
|
||||
|
||||
_kubectl_delete()
|
||||
|
@ -124,7 +124,7 @@ __kubectl_require_pod_and_container()
|
||||
|
||||
__custom_func() {
|
||||
case ${last_command} in
|
||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop | kubectl_edit)
|
||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop | kubectl_edit | kubectl_patch)
|
||||
__kubectl_get_resource
|
||||
return
|
||||
;;
|
||||
|
@ -63,6 +63,15 @@ kubectl patch pod valid-pod -type='json' -p='[{"op": "replace", "path": "/spec/c
|
||||
func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
options := &PatchOptions{}
|
||||
|
||||
// retrieve a list of handled resources from printer as valid args
|
||||
validArgs, argAliases := []string{}, []string{}
|
||||
p, err := f.Printer(nil, false, false, false, false, false, false, []string{})
|
||||
cmdutil.CheckErr(err)
|
||||
if p != nil {
|
||||
validArgs = p.HandledResources()
|
||||
argAliases = kubectl.ResourceAliases(validArgs)
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "patch (-f FILENAME | TYPE NAME) -p PATCH",
|
||||
Short: "Update field(s) of a resource using strategic merge patch.",
|
||||
@ -74,6 +83,8 @@ func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
err := RunPatch(f, out, cmd, args, shortOutput, options)
|
||||
cmdutil.CheckErr(err)
|
||||
},
|
||||
ValidArgs: validArgs,
|
||||
ArgAliases: argAliases,
|
||||
}
|
||||
cmd.Flags().StringP("patch", "p", "", "The patch to be applied to the resource JSON file.")
|
||||
cmd.MarkFlagRequired("patch")
|
||||
|
Loading…
Reference in New Issue
Block a user