Merge pull request #65786 from juanvallejo/jvallejo/update-template-printer-check

Automatic merge from submit-queue (batch tested with PRs 65715, 65786). 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>.

update --template printer defaulting

**Release note**:
```release-note
NONE
```

Depends on https://github.com/kubernetes/kubernetes/pull/65711
The relevant commit for this PR is the last one (`
fix go-template defaulting for commands w default output format`)

cc @deads2k @soltysh
This commit is contained in:
Kubernetes Submit Queue
2018-07-04 06:18:08 -07:00
committed by GitHub
2 changed files with 29 additions and 7 deletions

View File

@@ -1777,10 +1777,6 @@ run_template_output_tests() {
output_message=$(kubectl "${kube_flags[@]}" auth reconcile --dry-run -f test/fixtures/pkg/kubectl/cmd/auth/rbac-resource-plus.yaml --template="{{ .metadata.name }}:")
kube::test::if_has_string "${output_message}" 'testing-CR:testing-CRB:testing-RB:testing-R:'
# check that "config view" command supports --template output
output_message=$(kubectl "${kube_flags[@]}" config view --output=go-template="{{ .kind }}:")
kube::test::if_has_string "${output_message}" 'Config'
# check that "create clusterrole" command supports --template output
output_message=$(kubectl "${kube_flags[@]}" create clusterrole --template="{{ .metadata.name }}:" --verb get myclusterrole --non-resource-url /logs/ --resource pods)
kube::test::if_has_string "${output_message}" 'myclusterrole:'
@@ -1901,6 +1897,22 @@ EOF
output_message=$(kubectl "${kube_flags[@]}" create service nodeport foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
kube::test::if_has_string "${output_message}" 'foo:'
# check that "config view" ouputs "yaml" as its default output format
output_message=$(kubectl "${kube_flags[@]}" config view)
kube::test::if_has_string "${output_message}" 'kind: Config'
# check that "config view" command supports --template output
# and that commands that set a default output (yaml in this case),
# default to "go-template" as their output format when a --template
# value is provided, but no explicit --output format is given.
output_message=$(kubectl "${kube_flags[@]}" config view --template="{{ .kind }}:")
kube::test::if_has_string "${output_message}" 'Config'
# check that running a command with both a --template flag and a
# non-template --output prefers the non-template output value
output_message=$(kubectl "${kube_flags[@]}" create configmap cm --dry-run --template="{{ .metadata.name }}:" --output yaml)
kube::test::if_has_string "${output_message}" 'kind: ConfigMap'
# cleanup
kubectl delete cronjob pi "${kube_flags[@]}"
kubectl delete pods --all "${kube_flags[@]}"