Skip to content

Commit d885863

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#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. ```
2 parents c6c0347 + 1989aa5 commit d885863

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/kubectl/cmd/apply_view_last_applied.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func NewViewLastAppliedOptions(out, err io.Writer) *ViewLastAppliedOptions {
6767

6868
func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
6969
options := NewViewLastAppliedOptions(out, err)
70+
validArgs := cmdutil.ValidArgList(f)
71+
7072
cmd := &cobra.Command{
7173
Use: "view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)",
7274
DisableFlagsInUseLine: true,
@@ -78,6 +80,8 @@ func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Co
7880
cmdutil.CheckErr(options.Validate(cmd))
7981
cmdutil.CheckErr(options.RunApplyViewLastApplied(cmd))
8082
},
83+
ValidArgs: validArgs,
84+
ArgAliases: kubectl.ResourceAliases(validArgs),
8185
}
8286

8387
cmd.Flags().StringVarP(&options.OutputFormat, "output", "o", options.OutputFormat, "Output format. Must be one of yaml|json")

pkg/kubectl/cmd/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ __kubectl_require_pod_and_container()
168168
__custom_func() {
169169
case ${last_command} in
170170
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_edit | kubectl_patch |\
171-
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*)
171+
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_* |\
172+
kubectl_apply_edit-last-applied | kubectl_apply_view-last-applied)
172173
__kubectl_get_resource
173174
return
174175
;;

0 commit comments

Comments
 (0)