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

fix(cheatsheet): update context cmd description #15935

Merged
merged 3 commits into from
Oct 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/en/docs/reference/kubectl/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ kubectl config view
# get the password for the e2e user
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'

kubectl config view -o jsonpath='{.users[].name}' # get a list of users
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanyC97 guess you can confirm this as you added the line in #13257 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, .users[].name should list all users, not just the first user. Are you sure that you don't just have a single user on the system?

Copy link
Contributor Author

@petermikitsh petermikitsh Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have multiple users in ~/.kube/config:

apiVersion: v1
clusters:
current-context: snow-cluster
kind: Config
preferences: {}
users:
- name: foo
  user:
    token: abc123
- name: bar
  user:
    token: xyz456

kubectl config view -o jsonpath='{.users[].name}' outputs bar

kubectl config view -o jsonpath='{.users[0].name}' also outputs bar

kubectl config view -o jsonpath='{.users[1].name}' outputs foo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2019-08-20 at 9 58 51 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, interesting. Perhaps this is a difference between jq and the jsonpath flag for kubectl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaypipes I hope this illustrates that get a list of users may not be the best description of the command

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it does! :)

kubectl config view -o jsonpath='{.users[].name}' # display the first user
kubectl config get-contexts # display list of contexts
kubectl config current-context # display the current-context
kubectl config use-context my-cluster-name # set the default context to my-cluster-name
Expand Down