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

Change kubectl help/examples to use jsonpath instead of template #18533

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/man/man1/kubectl-config-view.1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kubectl config view \- Displays merged kubeconfig settings or a specified kubeco
Displays merged kubeconfig settings or a specified kubeconfig file.

.PP
You can use \-\-output=template \-\-template=TEMPLATE to extract specific values.
You can use \-\-output jsonpath={...} to extract specific values using a jsonpath expression.


.SH OPTIONS
Expand Down Expand Up @@ -167,7 +167,7 @@ You can use \-\-output=template \-\-template=TEMPLATE to extract specific values
$ kubectl config view

# Get the password for the e2e user
$ kubectl config view \-o template \-\-template='{{range .users}}{{ if eq .name "e2e" }}{{ index .user.password }}{{end}}{{end}}'
$ kubectl config view \-o jsonpath='{.users[?(@.name == "e2e")].user.password}'

.fi
.RE
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/kubectl/kubectl_config_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Displays merged kubeconfig settings or a specified kubeconfig file.

Displays merged kubeconfig settings or a specified kubeconfig file.

You can use --output=template --template=TEMPLATE to extract specific values.
You can use --output jsonpath={...} to extract specific values using a jsonpath expression.

```
kubectl config view
Expand All @@ -54,7 +54,7 @@ kubectl config view
$ kubectl config view

# Get the password for the e2e user
$ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2e" }}{{ index .user.password }}{{end}}{{end}}'
$ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
```

### Options
Expand Down Expand Up @@ -104,7 +104,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2

* [kubectl config](kubectl_config.md) - config modifies kubeconfig files

###### Auto generated by spf13/cobra on 8-Jan-2016
###### Auto generated by spf13/cobra on 28-Jan-2016

<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]()
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubectl/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func NewCmdConfig(pathOptions *PathOptions, out io.Writer) *cobra.Command {
Long: `config modifies kubeconfig files using subcommands like "kubectl config set current-context my-context"

The loading order follows these rules:
1. If the --` + pathOptions.ExplicitFileFlag + ` flag is set, then only that file is loaded. The flag may only be set once and no merging takes place.
2. If $` + pathOptions.EnvVar + ` environment variable is set, then it is used a list of paths (normal path delimitting rules for your system). These paths are merged together. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list.
3. Otherwise, ` + path.Join("${HOME}", pathOptions.GlobalFileSubpath) + ` is used and no merging takes place.
1. If the --` + pathOptions.ExplicitFileFlag + ` flag is set, then only that file is loaded. The flag may only be set once and no merging takes place.
2. If $` + pathOptions.EnvVar + ` environment variable is set, then it is used a list of paths (normal path delimitting rules for your system). These paths are merged together. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list.
3. Otherwise, ` + path.Join("${HOME}", pathOptions.GlobalFileSubpath) + ` is used and no merging takes place.
`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/config/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ type ViewOptions struct {
const (
view_long = `Displays merged kubeconfig settings or a specified kubeconfig file.

You can use --output=template --template=TEMPLATE to extract specific values.`
You can use --output jsonpath={...} to extract specific values using a jsonpath expression.`
view_example = `# Show Merged kubeconfig settings.
$ kubectl config view

# Get the password for the e2e user
$ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2e" }}{{ index .user.password }}{{end}}{{end}}'`
$ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'`
)

func NewCmdConfigView(out io.Writer, ConfigAccess ConfigAccess) *cobra.Command {
Expand Down