Commit 9441721f authored by Daniel Smith's avatar Daniel Smith

Merge pull request #19689 from AdoHe/kubectl_label_display

kubectl add show-labels flag to make it more readable
parents 1c7b5e12 714d12cf
...@@ -282,6 +282,7 @@ _kubectl_get() ...@@ -282,6 +282,7 @@ _kubectl_get()
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -1060,6 +1061,7 @@ _kubectl_rolling-update() ...@@ -1060,6 +1061,7 @@ _kubectl_rolling-update()
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -1496,6 +1498,7 @@ _kubectl_run() ...@@ -1496,6 +1498,7 @@ _kubectl_run()
flags+=("--service-overrides=") flags+=("--service-overrides=")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--stdin") flags+=("--stdin")
flags+=("-i") flags+=("-i")
...@@ -1570,6 +1573,7 @@ _kubectl_expose() ...@@ -1570,6 +1573,7 @@ _kubectl_expose()
flags+=("--session-affinity=") flags+=("--session-affinity=")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--target-port=") flags+=("--target-port=")
flags+=("--template=") flags+=("--template=")
...@@ -1634,6 +1638,7 @@ _kubectl_autoscale() ...@@ -1634,6 +1638,7 @@ _kubectl_autoscale()
flags+=("--save-config") flags+=("--save-config")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -1921,6 +1926,7 @@ _kubectl_label() ...@@ -1921,6 +1926,7 @@ _kubectl_label()
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -2004,6 +2010,7 @@ _kubectl_annotate() ...@@ -2004,6 +2010,7 @@ _kubectl_annotate()
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -2056,6 +2063,7 @@ _kubectl_config_view() ...@@ -2056,6 +2063,7 @@ _kubectl_config_view()
flags+=("--raw") flags+=("--raw")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -2592,6 +2600,7 @@ _kubectl_convert() ...@@ -2592,6 +2600,7 @@ _kubectl_convert()
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
flags+=("--show-labels")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
......
...@@ -72,6 +72,10 @@ horizontalpodautoscalers (hpa), resourcequotas (quota) or secrets. ...@@ -72,6 +72,10 @@ horizontalpodautoscalers (hpa), resourcequotas (quota) or secrets.
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -76,6 +76,10 @@ An autoscaler can automatically increase or decrease number of pods deployed wit ...@@ -76,6 +76,10 @@ An autoscaler can automatically increase or decrease number of pods deployed wit
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -55,6 +55,10 @@ You can use \-\-output jsonpath={...} to extract specific values using a jsonpat ...@@ -55,6 +55,10 @@ You can use \-\-output jsonpath={...} to extract specific values using a jsonpat
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -58,6 +58,10 @@ to change to output destination. ...@@ -58,6 +58,10 @@ to change to output destination.
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -106,6 +106,10 @@ the new service will re\-use the labels from the resource it exposes. ...@@ -106,6 +106,10 @@ the new service will re\-use the labels from the resource it exposes.
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -67,6 +67,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource( ...@@ -67,6 +67,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource(
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -69,6 +69,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi ...@@ -69,6 +69,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -73,6 +73,10 @@ existing replication controller and overwrite at least one (common) label in its ...@@ -73,6 +73,10 @@ existing replication controller and overwrite at least one (common) label in its
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -121,6 +121,10 @@ Creates a replication controller or job to manage the created container(s). ...@@ -121,6 +121,10 @@ Creates a replication controller or job to manage the created container(s).
When printing, show all resources (default hide terminated pods.) When printing, show all resources (default hide terminated pods.)
.PP .PP
\fB\-\-show\-labels\fP=false
When printing, show all labels as the last column (default hide labels column)
.PP
\fB\-\-sort\-by\fP="" \fB\-\-sort\-by\fP=""
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
......
...@@ -92,6 +92,7 @@ $ kubectl annotate pods foo description- ...@@ -92,6 +92,7 @@ $ kubectl annotate pods foo description-
--resource-version="": If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. --resource-version="": If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
-l, --selector="": Selector (label query) to filter on -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
``` ```
......
...@@ -74,6 +74,7 @@ $ kubectl autoscale rc foo --max=5 --cpu-percent=80 ...@@ -74,6 +74,7 @@ $ kubectl autoscale rc foo --max=5 --cpu-percent=80
--record[=false]: Record current kubectl command in the resource annotation. --record[=false]: Record current kubectl command in the resource annotation.
--save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future. --save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
``` ```
......
...@@ -68,6 +68,7 @@ $ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}' ...@@ -68,6 +68,7 @@ $ kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
--output-version="": Output the formatted object with the given version (default api-version). --output-version="": Output the formatted object with the given version (default api-version).
--raw[=false]: display raw byte data --raw[=false]: display raw byte data
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
``` ```
......
...@@ -74,6 +74,7 @@ $ kubectl convert -f . | kubectl create -f - ...@@ -74,6 +74,7 @@ $ kubectl convert -f . | kubectl create -f -
--output-version="": Output the formatted object with the given version (default api-version). --output-version="": Output the formatted object with the given version (default api-version).
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema' --schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--validate[=true]: If true, use a schema to validate the input before sending it --validate[=true]: If true, use a schema to validate the input before sending it
...@@ -111,7 +112,7 @@ $ kubectl convert -f . | kubectl create -f - ...@@ -111,7 +112,7 @@ $ kubectl convert -f . | kubectl create -f -
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 24-Nov-2015 ###### Auto generated by spf13/cobra on 20-Jan-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]()
......
...@@ -91,6 +91,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream ...@@ -91,6 +91,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
--selector="": A label selector to use for this service. If empty (the default) infer the selector from the replication controller. --selector="": A label selector to use for this service. If empty (the default) infer the selector from the replication controller.
--session-affinity="": If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP' --session-affinity="": If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--target-port="": Name or number for the port on the container that the service should direct traffic to. Optional. --target-port="": Name or number for the port on the container that the service should direct traffic to. Optional.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
......
...@@ -94,6 +94,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 ...@@ -94,6 +94,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7
--output-version="": Output the formatted object with the given version (default api-version). --output-version="": Output the formatted object with the given version (default api-version).
-l, --selector="": Selector (label query) to filter on -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
-w, --watch[=false]: After listing/getting the requested object, watch for changes. -w, --watch[=false]: After listing/getting the requested object, watch for changes.
...@@ -132,7 +133,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 ...@@ -132,7 +133,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 22-Dec-2015 ###### Auto generated by spf13/cobra on 20-Jan-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_get.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_get.md?pixel)]()
......
...@@ -86,6 +86,7 @@ $ kubectl label pods foo bar- ...@@ -86,6 +86,7 @@ $ kubectl label pods foo bar-
--resource-version="": If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. --resource-version="": If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
-l, --selector="": Selector (label query) to filter on -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
``` ```
......
...@@ -85,6 +85,7 @@ $ kubectl rolling-update frontend-v1 frontend-v2 --rollback ...@@ -85,6 +85,7 @@ $ kubectl rolling-update frontend-v1 frontend-v2 --rollback
--rollback[=false]: If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout --rollback[=false]: If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema' --schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--timeout=5m0s: Max time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --timeout=5m0s: Max time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
...@@ -124,7 +125,7 @@ $ kubectl rolling-update frontend-v1 frontend-v2 --rollback ...@@ -124,7 +125,7 @@ $ kubectl rolling-update frontend-v1 frontend-v2 --rollback
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 8-Dec-2015 ###### Auto generated by spf13/cobra on 20-Jan-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]()
......
...@@ -108,6 +108,7 @@ $ kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri ...@@ -108,6 +108,7 @@ $ kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri
--service-generator="service/v2": The name of the generator to use for creating a service. Only used if --expose is true --service-generator="service/v2": The name of the generator to use for creating a service. Only used if --expose is true
--service-overrides="": An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true. --service-overrides="": An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true.
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
-i, --stdin[=false]: Keep stdin open on the container(s) in the pod, even if nothing is attached. -i, --stdin[=false]: Keep stdin open on the container(s) in the pod, even if nothing is attached.
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
......
...@@ -327,6 +327,7 @@ service-overrides ...@@ -327,6 +327,7 @@ service-overrides
service-sync-period service-sync-period
session-affinity session-affinity
show-all show-all
show-labels
shutdown-fd shutdown-fd
shutdown-fifo shutdown-fifo
since-seconds since-seconds
......
...@@ -195,7 +195,7 @@ func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) { ...@@ -195,7 +195,7 @@ func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
Describer: func(*meta.RESTMapping) (kubectl.Describer, error) { Describer: func(*meta.RESTMapping) (kubectl.Describer, error) {
return t.Describer, t.Err return t.Describer, t.Err
}, },
Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, showLabels bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return t.Printer, t.Err return t.Printer, t.Err
}, },
Validator: func(validate bool, cacheDir string) (validation.Schema, error) { Validator: func(validate bool, cacheDir string) (validation.Schema, error) {
...@@ -253,7 +253,7 @@ func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) { ...@@ -253,7 +253,7 @@ func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
Describer: func(*meta.RESTMapping) (kubectl.Describer, error) { Describer: func(*meta.RESTMapping) (kubectl.Describer, error) {
return t.Describer, t.Err return t.Describer, t.Err
}, },
Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, showLabels bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return t.Printer, t.Err return t.Printer, t.Err
}, },
Validator: func(validate bool, cacheDir string) (validation.Schema, error) { Validator: func(validate bool, cacheDir string) (validation.Schema, error) {
...@@ -327,7 +327,7 @@ func stringBody(body string) io.ReadCloser { ...@@ -327,7 +327,7 @@ func stringBody(body string) io.ReadCloser {
func ExamplePrintReplicationControllerWithNamespace() { func ExamplePrintReplicationControllerWithNamespace() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, false, []string{})
tf.Client = &fake.RESTClient{ tf.Client = &fake.RESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -369,7 +369,7 @@ func ExamplePrintReplicationControllerWithNamespace() { ...@@ -369,7 +369,7 @@ func ExamplePrintReplicationControllerWithNamespace() {
func ExamplePrintPodWithWideFormat() { func ExamplePrintPodWithWideFormat() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, false, false, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, false, false, false, []string{})
tf.Client = &fake.RESTClient{ tf.Client = &fake.RESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -402,6 +402,45 @@ func ExamplePrintPodWithWideFormat() { ...@@ -402,6 +402,45 @@ func ExamplePrintPodWithWideFormat() {
// test1 1/2 podPhase 6 10y kubernetes-minion-abcd // test1 1/2 podPhase 6 10y kubernetes-minion-abcd
} }
func ExamplePrintPodWithShowLabels() {
f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, true, false, []string{})
tf.Client = &fake.RESTClient{
Codec: codec,
Client: nil,
}
nodeName := "kubernetes-minion-abcd"
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "test1",
CreationTimestamp: unversioned.Time{Time: time.Now().AddDate(-10, 0, 0)},
Labels: map[string]string{
"l1": "key",
"l2": "value",
},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: "podPhase",
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
}
err := f.PrintObject(cmd, pod, os.Stdout)
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
// Output:
// NAME READY STATUS RESTARTS AGE LABELS
// test1 1/2 podPhase 6 10y l1=key,l2=value
}
func newAllPhasePodList() *api.PodList { func newAllPhasePodList() *api.PodList {
nodeName := "kubernetes-minion-abcd" nodeName := "kubernetes-minion-abcd"
return &api.PodList{ return &api.PodList{
...@@ -496,7 +535,7 @@ func newAllPhasePodList() *api.PodList { ...@@ -496,7 +535,7 @@ func newAllPhasePodList() *api.PodList {
func ExamplePrintPodHideTerminated() { func ExamplePrintPodHideTerminated() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, false, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
tf.Client = &fake.RESTClient{ tf.Client = &fake.RESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -516,7 +555,7 @@ func ExamplePrintPodHideTerminated() { ...@@ -516,7 +555,7 @@ func ExamplePrintPodHideTerminated() {
func ExamplePrintPodShowAll() { func ExamplePrintPodShowAll() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, true, false, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, true, false, false, []string{})
tf.Client = &fake.RESTClient{ tf.Client = &fake.RESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -538,7 +577,7 @@ func ExamplePrintPodShowAll() { ...@@ -538,7 +577,7 @@ func ExamplePrintPodShowAll() {
func ExamplePrintServiceWithNamespacesAndLabels() { func ExamplePrintServiceWithNamespacesAndLabels() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, []string{"l1"}) tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, false, []string{"l1"})
tf.Client = &fake.RESTClient{ tf.Client = &fake.RESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
......
...@@ -71,7 +71,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command { ...@@ -71,7 +71,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
// retrieve a list of handled resources from printer as valid args // retrieve a list of handled resources from printer as valid args
validArgs := []string{} validArgs := []string{}
p, err := f.Printer(nil, false, false, false, false, false, []string{}) p, err := f.Printer(nil, false, false, false, false, false, false, []string{})
cmdutil.CheckErr(err) cmdutil.CheckErr(err)
if p != nil { if p != nil {
validArgs = p.HandledResources() validArgs = p.HandledResources()
......
...@@ -78,7 +78,7 @@ func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command { ...@@ -78,7 +78,7 @@ func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command {
// retrieve a list of handled resources from printer as valid args // retrieve a list of handled resources from printer as valid args
validArgs := []string{} validArgs := []string{}
p, err := f.Printer(nil, false, false, false, false, false, []string{}) p, err := f.Printer(nil, false, false, false, false, false, false, []string{})
cmdutil.CheckErr(err) cmdutil.CheckErr(err)
if p != nil { if p != nil {
validArgs = p.HandledResources() validArgs = p.HandledResources()
......
...@@ -72,7 +72,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command { ...@@ -72,7 +72,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
// retrieve a list of handled resources from printer as valid args // retrieve a list of handled resources from printer as valid args
validArgs := []string{} validArgs := []string{}
p, err := f.Printer(nil, false, false, false, false, false, []string{}) p, err := f.Printer(nil, false, false, false, false, false, false, []string{})
cmdutil.CheckErr(err) cmdutil.CheckErr(err)
if p != nil { if p != nil {
validArgs = p.HandledResources() validArgs = p.HandledResources()
......
...@@ -83,7 +83,7 @@ type Factory struct { ...@@ -83,7 +83,7 @@ type Factory struct {
// Returns a Describer for displaying the specified RESTMapping type or an error. // Returns a Describer for displaying the specified RESTMapping type or an error.
Describer func(mapping *meta.RESTMapping) (kubectl.Describer, error) Describer func(mapping *meta.RESTMapping) (kubectl.Describer, error)
// Returns a Printer for formatting objects of the given type or an error. // Returns a Printer for formatting objects of the given type or an error.
Printer func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) Printer func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, showLabels bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error)
// Returns a Scaler for changing the size of the specified RESTMapping type or an error // Returns a Scaler for changing the size of the specified RESTMapping type or an error
Scaler func(mapping *meta.RESTMapping) (kubectl.Scaler, error) Scaler func(mapping *meta.RESTMapping) (kubectl.Scaler, error)
// Returns a Reaper for gracefully shutting down resources. // Returns a Reaper for gracefully shutting down resources.
...@@ -238,8 +238,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory { ...@@ -238,8 +238,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
JSONEncoder: func() runtime.Encoder { JSONEncoder: func() runtime.Encoder {
return api.Codecs.LegacyCodec(registered.EnabledVersions()...) return api.Codecs.LegacyCodec(registered.EnabledVersions()...)
}, },
Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, showLabels bool, absoluteTimestamps bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return kubectl.NewHumanReadablePrinter(noHeaders, withNamespace, wide, showAll, absoluteTimestamps, columnLabels), nil return kubectl.NewHumanReadablePrinter(noHeaders, withNamespace, wide, showAll, showLabels, absoluteTimestamps, columnLabels), nil
}, },
PodSelectorForObject: func(object runtime.Object) (string, error) { PodSelectorForObject: func(object runtime.Object) (string, error) {
// TODO: replace with a swagger schema based approach (identify pod selector via schema introspection) // TODO: replace with a swagger schema based approach (identify pod selector via schema introspection)
...@@ -753,7 +753,7 @@ func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMappin ...@@ -753,7 +753,7 @@ func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMappin
if err != nil { if err != nil {
columnLabel = []string{} columnLabel = []string{}
} }
printer, err = f.Printer(mapping, GetFlagBool(cmd, "no-headers"), withNamespace, GetWideFlag(cmd), GetFlagBool(cmd, "show-all"), isWatch(cmd), columnLabel) printer, err = f.Printer(mapping, GetFlagBool(cmd, "no-headers"), withNamespace, GetWideFlag(cmd), GetFlagBool(cmd, "show-all"), GetFlagBool(cmd, "show-labels"), isWatch(cmd), columnLabel)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -33,6 +33,7 @@ func AddPrinterFlags(cmd *cobra.Command) { ...@@ -33,6 +33,7 @@ func AddPrinterFlags(cmd *cobra.Command) {
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md].") cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md].")
cmd.Flags().String("output-version", "", "Output the formatted object with the given version (default api-version).") cmd.Flags().String("output-version", "", "Output the formatted object with the given version (default api-version).")
cmd.Flags().Bool("no-headers", false, "When using the default output, don't print headers.") cmd.Flags().Bool("no-headers", false, "When using the default output, don't print headers.")
cmd.Flags().Bool("show-labels", false, "When printing, show all labels as the last column (default hide labels column)")
// template shorthand -t is deprecated to support -t for --tty // template shorthand -t is deprecated to support -t for --tty
// TODO: remove template flag shorthand -t // TODO: remove template flag shorthand -t
cmd.Flags().StringP("template", "t", "", "Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].") cmd.Flags().StringP("template", "t", "", "Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].")
......
...@@ -224,7 +224,7 @@ func ErrorPrintHandler(obj *TestPrintType, w io.Writer, options PrintOptions) er ...@@ -224,7 +224,7 @@ func ErrorPrintHandler(obj *TestPrintType, w io.Writer, options PrintOptions) er
func TestCustomTypePrinting(t *testing.T) { func TestCustomTypePrinting(t *testing.T) {
columns := []string{"Data"} columns := []string{"Data"}
printer := NewHumanReadablePrinter(false, false, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
printer.Handler(columns, PrintCustomType) printer.Handler(columns, PrintCustomType)
obj := TestPrintType{"test object"} obj := TestPrintType{"test object"}
...@@ -241,7 +241,7 @@ func TestCustomTypePrinting(t *testing.T) { ...@@ -241,7 +241,7 @@ func TestCustomTypePrinting(t *testing.T) {
func TestPrintHandlerError(t *testing.T) { func TestPrintHandlerError(t *testing.T) {
columns := []string{"Data"} columns := []string{"Data"}
printer := NewHumanReadablePrinter(false, false, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
printer.Handler(columns, ErrorPrintHandler) printer.Handler(columns, ErrorPrintHandler)
obj := TestPrintType{"test object"} obj := TestPrintType{"test object"}
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
...@@ -252,7 +252,7 @@ func TestPrintHandlerError(t *testing.T) { ...@@ -252,7 +252,7 @@ func TestPrintHandlerError(t *testing.T) {
} }
func TestUnknownTypePrinting(t *testing.T) { func TestUnknownTypePrinting(t *testing.T) {
printer := NewHumanReadablePrinter(false, false, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
err := printer.PrintObj(&TestUnknownType{}, buffer) err := printer.PrintObj(&TestUnknownType{}, buffer)
if err == nil { if err == nil {
...@@ -456,8 +456,8 @@ func TestPrinters(t *testing.T) { ...@@ -456,8 +456,8 @@ func TestPrinters(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
printers := map[string]ResourcePrinter{ printers := map[string]ResourcePrinter{
"humanReadable": NewHumanReadablePrinter(true, false, false, false, false, []string{}), "humanReadable": NewHumanReadablePrinter(true, false, false, false, false, false, []string{}),
"humanReadableHeaders": NewHumanReadablePrinter(false, false, false, false, false, []string{}), "humanReadableHeaders": NewHumanReadablePrinter(false, false, false, false, false, false, []string{}),
"json": &JSONPrinter{}, "json": &JSONPrinter{},
"yaml": &YAMLPrinter{}, "yaml": &YAMLPrinter{},
"template": templatePrinter, "template": templatePrinter,
...@@ -500,7 +500,7 @@ func TestPrinters(t *testing.T) { ...@@ -500,7 +500,7 @@ func TestPrinters(t *testing.T) {
func TestPrintEventsResultSorted(t *testing.T) { func TestPrintEventsResultSorted(t *testing.T) {
// Arrange // Arrange
printer := NewHumanReadablePrinter(false /* noHeaders */, false, false, false, false, []string{}) printer := NewHumanReadablePrinter(false /* noHeaders */, false, false, false, false, false, []string{})
obj := api.EventList{ obj := api.EventList{
Items: []api.Event{ Items: []api.Event{
...@@ -544,7 +544,7 @@ func TestPrintEventsResultSorted(t *testing.T) { ...@@ -544,7 +544,7 @@ func TestPrintEventsResultSorted(t *testing.T) {
} }
func TestPrintNodeStatus(t *testing.T) { func TestPrintNodeStatus(t *testing.T) {
printer := NewHumanReadablePrinter(false, false, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
table := []struct { table := []struct {
node api.Node node api.Node
status string status string
...@@ -755,7 +755,7 @@ func TestPrintHumanReadableService(t *testing.T) { ...@@ -755,7 +755,7 @@ func TestPrintHumanReadableService(t *testing.T) {
for _, svc := range tests { for _, svc := range tests {
buff := bytes.Buffer{} buff := bytes.Buffer{}
printService(&svc, &buff, PrintOptions{false, false, false, false, false, []string{}}) printService(&svc, &buff, PrintOptions{false, false, false, false, false, false, []string{}})
output := string(buff.Bytes()) output := string(buff.Bytes())
ip := svc.Spec.ClusterIP ip := svc.Spec.ClusterIP
if !strings.Contains(output, ip) { if !strings.Contains(output, ip) {
...@@ -937,7 +937,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) { ...@@ -937,7 +937,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) {
for _, test := range table { for _, test := range table {
if test.isNamespaced { if test.isNamespaced {
// Expect output to include namespace when requested. // Expect output to include namespace when requested.
printer := NewHumanReadablePrinter(false, true, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, true, false, false, false, false, []string{})
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
err := printer.PrintObj(test.obj, buffer) err := printer.PrintObj(test.obj, buffer)
if err != nil { if err != nil {
...@@ -949,7 +949,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) { ...@@ -949,7 +949,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) {
} }
} else { } else {
// Expect error when trying to get all namespaces for un-namespaced object. // Expect error when trying to get all namespaces for un-namespaced object.
printer := NewHumanReadablePrinter(false, true, false, false, false, []string{}) printer := NewHumanReadablePrinter(false, true, false, false, false, false, []string{})
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
err := printer.PrintObj(test.obj, buffer) err := printer.PrintObj(test.obj, buffer)
if err == nil { if err == nil {
...@@ -1044,7 +1044,7 @@ func TestPrintPod(t *testing.T) { ...@@ -1044,7 +1044,7 @@ func TestPrintPod(t *testing.T) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
for _, test := range tests { for _, test := range tests {
printPod(&test.pod, buf, PrintOptions{false, false, false, true, false, []string{}}) printPod(&test.pod, buf, PrintOptions{false, false, false, true, false, false, []string{}})
// We ignore time // We ignore time
if !strings.HasPrefix(buf.String(), test.expect) { if !strings.HasPrefix(buf.String(), test.expect) {
t.Fatalf("Expected: %s, got: %s", test.expect, buf.String()) t.Fatalf("Expected: %s, got: %s", test.expect, buf.String())
...@@ -1137,7 +1137,7 @@ func TestPrintNonTerminatedPod(t *testing.T) { ...@@ -1137,7 +1137,7 @@ func TestPrintNonTerminatedPod(t *testing.T) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
for _, test := range tests { for _, test := range tests {
printPod(&test.pod, buf, PrintOptions{false, false, false, false, false, []string{}}) printPod(&test.pod, buf, PrintOptions{false, false, false, false, false, false, []string{}})
// We ignore time // We ignore time
if !strings.HasPrefix(buf.String(), test.expect) { if !strings.HasPrefix(buf.String(), test.expect) {
t.Fatalf("Expected: %s, got: %s", test.expect, buf.String()) t.Fatalf("Expected: %s, got: %s", test.expect, buf.String())
...@@ -1197,7 +1197,7 @@ func TestPrintPodWithLabels(t *testing.T) { ...@@ -1197,7 +1197,7 @@ func TestPrintPodWithLabels(t *testing.T) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
for _, test := range tests { for _, test := range tests {
printPod(&test.pod, buf, PrintOptions{false, false, false, false, false, test.labelColumns}) printPod(&test.pod, buf, PrintOptions{false, false, false, false, false, false, test.labelColumns})
// We ignore time // We ignore time
if !strings.HasPrefix(buf.String(), test.startsWith) || !strings.HasSuffix(buf.String(), test.endsWith) { if !strings.HasPrefix(buf.String(), test.startsWith) || !strings.HasSuffix(buf.String(), test.endsWith) {
t.Fatalf("Expected to start with: %s and end with: %s, but got: %s", test.startsWith, test.endsWith, buf.String()) t.Fatalf("Expected to start with: %s and end with: %s, but got: %s", test.startsWith, test.endsWith, buf.String())
...@@ -1261,10 +1261,70 @@ func TestPrintDeployment(t *testing.T) { ...@@ -1261,10 +1261,70 @@ func TestPrintDeployment(t *testing.T) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
for _, test := range tests { for _, test := range tests {
printDeployment(&test.deployment, buf, PrintOptions{false, false, false, true, false, []string{}}) printDeployment(&test.deployment, buf, PrintOptions{false, false, false, true, false, false, []string{}})
if buf.String() != test.expect { if buf.String() != test.expect {
t.Fatalf("Expected: %s, got: %s", test.expect, buf.String()) t.Fatalf("Expected: %s, got: %s", test.expect, buf.String())
} }
buf.Reset() buf.Reset()
} }
} }
func TestPrintPodShowLabels(t *testing.T) {
tests := []struct {
pod api.Pod
startsWith string
endsWith string
showLabels bool
}{
{
// Test name, num of containers, restarts, container ready status
api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "test1",
Labels: map[string]string{"col1": "asd", "COL2": "zxc"},
},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: "podPhase",
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"test1\t1/2\tpodPhase\t6\t",
"\tCOL2=zxc,col1=asd\n",
true,
},
{
// Test name, num of containers, restarts, container ready status
api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "test1",
Labels: map[string]string{"col3": "asd", "COL4": "zxc"},
},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: "podPhase",
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"test1\t1/2\tpodPhase\t6\t",
"\n",
false,
},
}
buf := bytes.NewBuffer([]byte{})
for _, test := range tests {
printPod(&test.pod, buf, PrintOptions{false, false, false, false, test.showLabels, false, []string{}})
// We ignore time
if !strings.HasPrefix(buf.String(), test.startsWith) || !strings.HasSuffix(buf.String(), test.endsWith) {
t.Fatalf("Expected to start with: %s and end with: %s, but got: %s", test.startsWith, test.endsWith, buf.String())
}
buf.Reset()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment