Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support completions for --clusterrole of kubectl create clusterrolebinding #48267

Conversation

superbrothers
Copy link
Member

@superbrothers superbrothers commented Jun 29, 2017

What this PR does / why we need it:
This PR supports completion for --clusterrole of kubectl create clusterrolebinding.

$ kubectl create clusterrolebinding hoge --clusterrole <tab>
admin                                         system:controller:daemon-set-controller       system:controller:node-controller             system:controller:service-controller          system:kube-scheduler
cluster-admin                                 system:controller:deployment-controller       system:controller:persistent-volume-binder    system:controller:statefulset-controller      system:node
edit                                          system:controller:disruption-controller       system:controller:pod-garbage-collector       system:controller:ttl-controller              system:node-bootstrapper
system:auth-delegator                         system:controller:endpoint-controller         system:controller:replicaset-controller       system:discovery                              system:node-problem-detector
system:basic-user                             system:controller:generic-garbage-collector   system:controller:replication-controller      system:heapster                               system:node-proxier
system:controller:attachdetach-controller     system:controller:horizontal-pod-autoscaler   system:controller:resourcequota-controller    system:kube-aggregator                        system:persistent-volume-provisioner
system:controller:certificate-controller      system:controller:job-controller              system:controller:route-controller            system:kube-controller-manager                view
system:controller:cronjob-controller          system:controller:namespace-controller        system:controller:service-account-controller  system:kube-dns

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:

I feel that it is better to except system clusterroles from completion candidates. What do you think about it?

Release note:

Support completion for --clusterrole of kubectl create clusterrolebinding

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 29, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @superbrothers. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 29, 2017
@cblecker
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 29, 2017
@shiywang
Copy link
Contributor

/assign

@shiywang
Copy link
Contributor

shiywang commented Jul 31, 2017

@superbrothers sorry, I tried this command kubectl create clusterrolebinding test --clusterrole [TAB] with bash, but it doesn't works, is there anything wrong with my settting ?

[root@shiywang kubernetes]# echo $SHELL
/bin/bash

[root@shiywang kubernetes]# kubectl get clusterrole
NAME            AGE
secret-reader   2m

[root@shiywang kubernetes]# kubectl get nodes
NAME       STATUS    AGE       VERSION
minikube   Ready     22m       v1.7.0

[root@shiywang kubernetes]# kubectl create clusterrolebinding test123 --clusterrole --->TAB doesn't complete, but I have a clusterrole secret-reader right ?
api/                           docs/                          .idea/                         plugin/
_artifacts/                    examples/                      labels.yaml                    README.md
.bazelrc                       federation/                    LICENSE                        staging/
build/                         .gazelcfg.json                 logo/                          test/
BUILD.bazel                    .generated_files               .make/                         third_party/
CHANGELOG.md                   .git/                          Makefile                       translations/
cluster/                       .gitattributes                 Makefile.generated_files       Vagrantfile
cmd/                           .github/                       _output/                       vendor/
code-of-conduct.md             .gitignore                     OWNERS                         WORKSPACE
CONTRIBUTING.md                Godeps/                        OWNERS_ALIASES                 
.dockerized-kube-version-defs  hack/                          pkg/                           

[root@shiywang kubernetes]# kubectl version
Client Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.0-alpha.1.572+703c3b93448b15", GitCommit:"703c3b93448b1565c6ed4bde47dfedca85ddf53a", GitTreeState:"clean", BuildDate:"2017-07-31T06:42:44Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.0", GitCommit:"d3ada0119e776222f11ec7945e6d860061339aad", GitTreeState:"clean", BuildDate:"2017-06-30T10:17:58Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

@superbrothers
Copy link
Member Author

@shiywang Did you source the shell code outputed by kubectl completion bash? I tested on both bash and zsh.

$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ . /home/ksuda/.linuxbrew/etc/bash_completion
$ go build -o kubectl cmd/kubectl/kubectl.go
$ source <(./kubectl completion bash)
$ kubectl get clusterrole
NAME            KIND
secret-reader   ClusterRole.v1beta1.rbac.authorization.k8s.io
$ kubectl create clusterrolebinding test123 --clusterrole <TAB> # TAB complete `secret-reader` :)

@superbrothers
Copy link
Member Author

@shiywang ping

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 16, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 16, 2017
@superbrothers
Copy link
Member Author

@eparis @rootfs @shiywang Would you please review this PR?

@eparis
Copy link
Contributor

eparis commented Oct 4, 2017

/lgtm
/retest
/approve no-issue

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 4, 2017
@eparis
Copy link
Contributor

eparis commented Oct 4, 2017

/assign @brendandburns
super easy one brendan.

@brendandburns
Copy link
Contributor

/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, eparis, superbrothers

Associated issue requirement bypassed by: brendandburns

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all

Tests are more than 96 hours old. Re-running tests.

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 551c458 into kubernetes:master Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants