mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #60499 from superbrothers/last-applied
Automatic merge from submit-queue (batch tested with PRs 60499, 61715, 61688, 61300, 58787). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Support completion for kubectl apply view/edit-last-applied **What this PR does / why we need it**: With this PR, `kubectl apply view/edit-last-applied` support completion. ``` $ kubectl apply view-last-applied <tab> certificatesigningrequest configmap daemonset event job node pod podtemplate rolebinding serviceaccount storageclass clusterrolebinding controllerrevision deployment horizontalpodautoscaler namespace persistentvolume poddisruptionbudget replicaset secret statefulset componentstatus cronjob endpoints ingress networkpolicy persistentvolumeclaim podsecuritypolicy replicationcontroller service status $ kubectl apply view-last-applied deployment nginx<tab> nginx nginx2 ``` **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note `kubectl apply view/edit-last-applied support completion. ```
This commit is contained in:
commit
d885863793
@ -67,6 +67,8 @@ func NewViewLastAppliedOptions(out, err io.Writer) *ViewLastAppliedOptions {
|
||||
|
||||
func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
|
||||
options := NewViewLastAppliedOptions(out, err)
|
||||
validArgs := cmdutil.ValidArgList(f)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)",
|
||||
DisableFlagsInUseLine: true,
|
||||
@ -78,6 +80,8 @@ func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Co
|
||||
cmdutil.CheckErr(options.Validate(cmd))
|
||||
cmdutil.CheckErr(options.RunApplyViewLastApplied(cmd))
|
||||
},
|
||||
ValidArgs: validArgs,
|
||||
ArgAliases: kubectl.ResourceAliases(validArgs),
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&options.OutputFormat, "output", "o", options.OutputFormat, "Output format. Must be one of yaml|json")
|
||||
|
@ -168,7 +168,8 @@ __kubectl_require_pod_and_container()
|
||||
__custom_func() {
|
||||
case ${last_command} in
|
||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_edit | kubectl_patch |\
|
||||
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*)
|
||||
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_* |\
|
||||
kubectl_apply_edit-last-applied | kubectl_apply_view-last-applied)
|
||||
__kubectl_get_resource
|
||||
return
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user