• Kubernetes Submit Queue's avatar
    Merge pull request #54406 from superbrothers/kubectl-override-short-flags · 7f9f847c
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue. 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>.
    
    Improve 'kubectl completion` to override short flags
    
    **What this PR does / why we need it**: This PR improves `kubectl completion` to override short flags in
    addition to long flags. I tested this PR in both bash and zsh.
    
    ```
    # Complete pods name in the `default` namespace
    $ kubectl get po nginx-4217019353-<tab>
    nginx-4217019353-mw1pk  nginx-4217019353-rzw2c
    
    # Complete pods name in the `kube-system` namepace due to overriding the namespace
    $ kubectl -n kube-system get po kube<tab>
    kube-addon-manager-minikube  kube-dns-910330662-l9pwt     kubernetes-dashboard-9fbhm
    ```
    
    **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
    
    **Special notes for your reviewer**:
    
    **Release note**:
    
    ```release-note
    NONE
    ```
    7f9f847c
cmd.go 10.6 KB