Commit d42864b0 authored by Saad Ali's avatar Saad Ali

Merge pull request #12112 from JanetKuo/update-kubectl-get-pods-running

Hide terminated pods in 'kubectl' Printer by default
parents dcf3dca9 44a7a52a
...@@ -246,6 +246,8 @@ _kubectl_get() ...@@ -246,6 +246,8 @@ _kubectl_get()
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -511,6 +513,8 @@ _kubectl_rolling-update() ...@@ -511,6 +513,8 @@ _kubectl_rolling-update()
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--poll-interval=") flags+=("--poll-interval=")
flags+=("--rollback") flags+=("--rollback")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -675,6 +679,8 @@ _kubectl_run() ...@@ -675,6 +679,8 @@ _kubectl_run()
flags+=("--replicas=") flags+=("--replicas=")
two_word_flags+=("-r") two_word_flags+=("-r")
flags+=("--restart=") flags+=("--restart=")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--stdin") flags+=("--stdin")
flags+=("-i") flags+=("-i")
...@@ -753,6 +759,8 @@ _kubectl_expose() ...@@ -753,6 +759,8 @@ _kubectl_expose()
flags+=("--public-ip=") flags+=("--public-ip=")
flags+=("--selector=") flags+=("--selector=")
flags+=("--session-affinity=") flags+=("--session-affinity=")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--target-port=") flags+=("--target-port=")
flags+=("--template=") flags+=("--template=")
...@@ -791,6 +799,8 @@ _kubectl_label() ...@@ -791,6 +799,8 @@ _kubectl_label()
flags+=("--resource-version=") flags+=("--resource-version=")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -818,6 +828,8 @@ _kubectl_annotate() ...@@ -818,6 +828,8 @@ _kubectl_annotate()
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--overwrite") flags+=("--overwrite")
flags+=("--resource-version=") flags+=("--resource-version=")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
...@@ -846,6 +858,8 @@ _kubectl_config_view() ...@@ -846,6 +858,8 @@ _kubectl_config_view()
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--raw") flags+=("--raw")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=") flags+=("--sort-by=")
flags+=("--template=") flags+=("--template=")
two_word_flags+=("-t") two_word_flags+=("-t")
......
...@@ -58,6 +58,10 @@ resourcequotas (quota) or secrets. ...@@ -58,6 +58,10 @@ resourcequotas (quota) or secrets.
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. 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.
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -53,6 +53,10 @@ You can use \-\-output=template \-\-template=TEMPLATE to extract specific values ...@@ -53,6 +53,10 @@ You can use \-\-output=template \-\-template=TEMPLATE to extract specific values
display raw byte data display raw byte data
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -91,6 +91,10 @@ re\-use the labels from the resource it exposes. ...@@ -91,6 +91,10 @@ re\-use the labels from the resource it exposes.
If non\-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP' If non\-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -60,6 +60,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource( ...@@ -60,6 +60,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource(
Selector (label query) to filter on Selector (label query) to filter on
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -59,6 +59,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi ...@@ -59,6 +59,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi
Selector (label query) to filter on Selector (label query) to filter on
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -63,6 +63,10 @@ existing replication controller and overwrite at least one (common) label in its ...@@ -63,6 +63,10 @@ existing replication controller and overwrite at least one (common) label in its
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 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
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -79,6 +79,10 @@ Creates a replication controller to manage the created container(s). ...@@ -79,6 +79,10 @@ Creates a replication controller to manage the created container(s).
The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, only the Pod is created and \-\-replicas must be 1. Default 'Always' The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, only the Pod is created and \-\-replicas must be 1. Default 'Always'
.PP .PP
\fB\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)
.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.
......
...@@ -85,6 +85,7 @@ $ kubectl annotate pods foo description- ...@@ -85,6 +85,7 @@ $ kubectl annotate pods foo description-
--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).
--overwrite[=false]: If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. --overwrite[=false]: If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.
--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.
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
``` ```
...@@ -122,7 +123,7 @@ $ kubectl annotate pods foo description- ...@@ -122,7 +123,7 @@ $ kubectl annotate pods foo description-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-10 20:35:06.431305933 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.97715989 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]()
......
...@@ -67,6 +67,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 ...@@ -67,6 +67,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2
-o, --output="": Output format. One of: json|yaml|template|templatefile|wide. -o, --output="": Output format. One of: json|yaml|template|templatefile|wide.
--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.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
``` ```
...@@ -104,7 +105,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 ...@@ -104,7 +105,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files * [kubectl config](kubectl_config.md) - config modifies kubeconfig files
###### Auto generated by spf13/cobra at 2015-08-12 23:41:01.310054033 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.977277472 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]()
......
...@@ -84,6 +84,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream ...@@ -84,6 +84,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
--public-ip="": Name of a public IP address to set for the service. The service will be assigned this IP in addition to its generated service IP. --public-ip="": Name of a public IP address to set for the service. The service will be assigned this IP in addition to its generated service IP.
--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.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
...@@ -123,7 +124,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream ...@@ -123,7 +124,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-12 23:41:01.308576759 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.976918949 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_expose.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_expose.md?pixel)]()
......
...@@ -49,7 +49,7 @@ By specifying the output as 'template' and providing a Go template as the value ...@@ -49,7 +49,7 @@ By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s). of the --template flag, you can filter the attributes of the fetched resource(s).
``` ```
kubectl get [(-o|--output=)json|yaml|template|wide|...] (TYPE [(NAME | -l label] | TYPE/NAME ...) kubectl get [(-o|--output=)json|yaml|template|wide|...] (TYPE [(NAME | -l label] | TYPE/NAME ...) [flags]
``` ```
### Examples ### Examples
...@@ -91,6 +91,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 ...@@ -91,6 +91,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7
-o, --output="": Output format. One of: json|yaml|template|templatefile|wide. -o, --output="": Output format. One of: json|yaml|template|templatefile|wide.
--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.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. 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.
...@@ -130,7 +131,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 ...@@ -130,7 +131,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 at 2015-08-13 06:12:05.386038784 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.974605429 +0000 UTC
<!-- 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)]()
......
...@@ -83,6 +83,7 @@ $ kubectl label pods foo bar- ...@@ -83,6 +83,7 @@ $ kubectl label pods foo bar-
--overwrite[=false]: If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels. --overwrite[=false]: If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.
--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.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
``` ```
...@@ -120,7 +121,7 @@ $ kubectl label pods foo bar- ...@@ -120,7 +121,7 @@ $ kubectl label pods foo bar-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-13 02:21:16.349210188 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.977042997 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_label.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_label.md?pixel)]()
......
...@@ -79,6 +79,7 @@ $ kubectl rolling-update frontend --image=image:v2 ...@@ -79,6 +79,7 @@ $ kubectl rolling-update frontend --image=image:v2
--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).
--poll-interval=3s: Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --poll-interval=3s: Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--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
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. 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".
...@@ -118,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2 ...@@ -118,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-12 23:41:01.305486289 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.97558907 +0000 UTC
<!-- 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)]()
......
...@@ -88,6 +88,7 @@ $ kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN> ...@@ -88,6 +88,7 @@ $ kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
--port=-1: The port that this container exposes. --port=-1: The port that this container exposes.
-r, --replicas=1: Number of replicas to create for this container. Default is 1. -r, --replicas=1: Number of replicas to create for this container. Default is 1.
--restart="Always": The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, only the Pod is created and --replicas must be 1. Default 'Always' --restart="Always": The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a replication controller is created for this pod, if set to OnFailure or Never, only the Pod is created and --replicas must be 1. Default 'Always'
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--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.
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview] -t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
...@@ -127,7 +128,7 @@ $ kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN> ...@@ -127,7 +128,7 @@ $ kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-13 16:41:44.465440991 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-18 17:36:23.976238275 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_run.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_run.md?pixel)]()
......
...@@ -212,6 +212,7 @@ service-node-port-range ...@@ -212,6 +212,7 @@ service-node-port-range
service-node-ports service-node-ports
service-sync-period service-sync-period
session-affinity session-affinity
show-all
shutdown-fd shutdown-fd
shutdown-fifo shutdown-fifo
skip-munges skip-munges
......
...@@ -261,6 +261,7 @@ const ( ...@@ -261,6 +261,7 @@ const (
NodeUnschedulable = "spec.unschedulable" NodeUnschedulable = "spec.unschedulable"
ObjectNameField = "metadata.name" ObjectNameField = "metadata.name"
PodHost = "spec.nodeName" PodHost = "spec.nodeName"
PodStatus = "status.phase"
SecretType = "type" SecretType = "type"
EventReason = "reason" EventReason = "reason"
...@@ -318,7 +319,8 @@ var fieldMappings = versionToResourceToFieldMapping{ ...@@ -318,7 +319,8 @@ var fieldMappings = versionToResourceToFieldMapping{
NodeUnschedulable: "spec.unschedulable", NodeUnschedulable: "spec.unschedulable",
}, },
"pods": clientFieldNameToAPIVersionFieldName{ "pods": clientFieldNameToAPIVersionFieldName{
PodHost: "spec.nodeName", PodHost: "spec.nodeName",
PodStatus: "status.phase",
}, },
"secrets": clientFieldNameToAPIVersionFieldName{ "secrets": clientFieldNameToAPIVersionFieldName{
SecretType: "type", SecretType: "type",
......
...@@ -152,7 +152,7 @@ func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) { ...@@ -152,7 +152,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, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return t.Printer, t.Err return t.Printer, t.Err
}, },
Validator: func() (validation.Schema, error) { Validator: func() (validation.Schema, error) {
...@@ -207,7 +207,7 @@ func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) { ...@@ -207,7 +207,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, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return t.Printer, t.Err return t.Printer, t.Err
}, },
Validator: func() (validation.Schema, error) { Validator: func() (validation.Schema, error) {
...@@ -256,7 +256,7 @@ func stringBody(body string) io.ReadCloser { ...@@ -256,7 +256,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, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, []string{})
tf.Client = &client.FakeRESTClient{ tf.Client = &client.FakeRESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -298,7 +298,7 @@ func ExamplePrintReplicationControllerWithNamespace() { ...@@ -298,7 +298,7 @@ func ExamplePrintReplicationControllerWithNamespace() {
func ExamplePrintPodWithWideFormat() { func ExamplePrintPodWithWideFormat() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, []string{}) tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, false, []string{})
tf.Client = &client.FakeRESTClient{ tf.Client = &client.FakeRESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
...@@ -331,9 +331,143 @@ func ExamplePrintPodWithWideFormat() { ...@@ -331,9 +331,143 @@ func ExamplePrintPodWithWideFormat() {
// test1 1/2 podPhase 6 10y kubernetes-minion-abcd // test1 1/2 podPhase 6 10y kubernetes-minion-abcd
} }
func newAllPhasePodList() *api.PodList {
nodeName := "kubernetes-minion-abcd"
return &api.PodList{
Items: []api.Pod{
{
ObjectMeta: api.ObjectMeta{
Name: "test1",
CreationTimestamp: util.Time{time.Now().AddDate(-10, 0, 0)},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: api.PodPending,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "test2",
CreationTimestamp: util.Time{time.Now().AddDate(-10, 0, 0)},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: api.PodRunning,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "test3",
CreationTimestamp: util.Time{time.Now().AddDate(-10, 0, 0)},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: api.PodSucceeded,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "test4",
CreationTimestamp: util.Time{time.Now().AddDate(-10, 0, 0)},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: api.PodFailed,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "test5",
CreationTimestamp: util.Time{time.Now().AddDate(-10, 0, 0)},
},
Spec: api.PodSpec{
Containers: make([]api.Container, 2),
NodeName: nodeName,
},
Status: api.PodStatus{
Phase: api.PodUnknown,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
}},
}
}
func ExamplePrintPodHideTerminated() {
f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, []string{})
tf.Client = &client.FakeRESTClient{
Codec: codec,
Client: nil,
}
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
podList := newAllPhasePodList()
err := f.PrintObject(cmd, podList, os.Stdout)
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
// Output:
// NAME READY STATUS RESTARTS AGE
// test1 1/2 Pending 6 10y
// test2 1/2 Running 6 10y
// test5 1/2 Unknown 6 10y
}
func ExamplePrintPodShowAll() {
f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, true, []string{})
tf.Client = &client.FakeRESTClient{
Codec: codec,
Client: nil,
}
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
podList := newAllPhasePodList()
err := f.PrintObject(cmd, podList, os.Stdout)
if err != nil {
fmt.Printf("Unexpected error: %v", err)
}
// Output:
// NAME READY STATUS RESTARTS AGE
// test1 1/2 Pending 6 10y
// test2 1/2 Running 6 10y
// test3 1/2 Succeeded 6 10y
// test4 1/2 Failed 6 10y
// test5 1/2 Unknown 6 10y
}
func ExamplePrintServiceWithNamespacesAndLabels() { func ExamplePrintServiceWithNamespacesAndLabels() {
f, tf, codec := NewAPIFactory() f, tf, codec := NewAPIFactory()
tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, []string{"l1"}) tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, []string{"l1"})
tf.Client = &client.FakeRESTClient{ tf.Client = &client.FakeRESTClient{
Codec: codec, Codec: codec,
Client: nil, Client: nil,
......
...@@ -58,7 +58,7 @@ $ kubectl delete pods --all` ...@@ -58,7 +58,7 @@ $ kubectl delete pods --all`
) )
func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command { func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
p := kubectl.NewHumanReadablePrinter(false, false, false, []string{}) p := kubectl.NewHumanReadablePrinter(false, false, false, false, []string{})
validArgs := p.HandledResources() validArgs := p.HandledResources()
cmd := &cobra.Command{ cmd := &cobra.Command{
......
...@@ -65,11 +65,11 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7` ...@@ -65,11 +65,11 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7`
// NewCmdGet creates a command object for the generic "get" action, which // NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server. // retrieves one or more resources from a server.
func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command { func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command {
p := kubectl.NewHumanReadablePrinter(false, false, false, []string{}) p := kubectl.NewHumanReadablePrinter(false, false, false, false, []string{})
validArgs := p.HandledResources() validArgs := p.HandledResources()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "get [(-o|--output=)json|yaml|template|wide|...] (TYPE [(NAME | -l label] | TYPE/NAME ...)", Use: "get [(-o|--output=)json|yaml|template|wide|...] (TYPE [(NAME | -l label] | TYPE/NAME ...) [flags]",
Short: "Display one or many resources", Short: "Display one or many resources",
Long: get_long, Long: get_long,
Example: get_example, Example: get_example,
......
...@@ -328,6 +328,33 @@ func TestGetListObjects(t *testing.T) { ...@@ -328,6 +328,33 @@ func TestGetListObjects(t *testing.T) {
} }
} }
func TestGetAllListObjects(t *testing.T) {
pods, _, _ := testData()
f, tf, codec := NewAPIFactory()
tf.Printer = &testPrinter{}
tf.Client = &client.FakeRESTClient{
Codec: codec,
Resp: &http.Response{StatusCode: 200, Body: objBody(codec, pods)},
}
tf.Namespace = "test"
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdGet(f, buf)
cmd.SetOutput(buf)
cmd.Flags().Set("show-all", "true")
cmd.Run(cmd, []string{"pods"})
expected := []runtime.Object{pods}
actual := tf.Printer.(*testPrinter).Objects
if !reflect.DeepEqual(expected, actual) {
t.Errorf("unexpected object: %#v %#v", expected, actual)
}
if len(buf.String()) == 0 {
t.Errorf("unexpected empty output")
}
}
func TestGetListComponentStatus(t *testing.T) { func TestGetListComponentStatus(t *testing.T) {
statuses := testComponentStatusData() statuses := testComponentStatusData()
......
...@@ -67,7 +67,7 @@ type Factory struct { ...@@ -67,7 +67,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, columnLabels []string) (kubectl.ResourcePrinter, error) Printer func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll 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.
...@@ -179,8 +179,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory { ...@@ -179,8 +179,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
} }
return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind) return nil, fmt.Errorf("no description has been implemented for %q", mapping.Kind)
}, },
Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, columnLabels []string) (kubectl.ResourcePrinter, error) { Printer: func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, wide bool, showAll bool, columnLabels []string) (kubectl.ResourcePrinter, error) {
return kubectl.NewHumanReadablePrinter(noHeaders, withNamespace, wide, columnLabels), nil return kubectl.NewHumanReadablePrinter(noHeaders, withNamespace, wide, showAll, 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)
...@@ -461,7 +461,7 @@ func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMappin ...@@ -461,7 +461,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), columnLabel) printer, err = f.Printer(mapping, GetFlagBool(cmd, "no-headers"), withNamespace, GetWideFlag(cmd), GetFlagBool(cmd, "show-all"), 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().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().StringP("template", "t", "", "Template string or path to template file to use when -o=template or -o=templatefile. 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=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]")
cmd.Flags().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.") cmd.Flags().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.")
cmd.Flags().BoolP("show-all", "a", false, "When printing, show all resources (default hide terminated pods.)")
} }
// AddOutputFlagsForMutation adds output related flags to a command. Used by mutations only. // AddOutputFlagsForMutation adds output related flags to a command. Used by mutations only.
......
...@@ -19,7 +19,6 @@ package resource ...@@ -19,7 +19,6 @@ package resource
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta" "k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
...@@ -71,14 +70,13 @@ func (m *Helper) List(namespace, apiVersion string, selector labels.Selector) (r ...@@ -71,14 +70,13 @@ func (m *Helper) List(namespace, apiVersion string, selector labels.Selector) (r
Get() Get()
} }
func (m *Helper) Watch(namespace, resourceVersion, apiVersion string, labelSelector labels.Selector, fieldSelector fields.Selector) (watch.Interface, error) { func (m *Helper) Watch(namespace, resourceVersion, apiVersion string, labelSelector labels.Selector) (watch.Interface, error) {
return m.RESTClient.Get(). return m.RESTClient.Get().
Prefix("watch"). Prefix("watch").
NamespaceIfScoped(namespace, m.NamespaceScoped). NamespaceIfScoped(namespace, m.NamespaceScoped).
Resource(m.Resource). Resource(m.Resource).
Param("resourceVersion", resourceVersion). Param("resourceVersion", resourceVersion).
LabelsSelectorParam(labelSelector). LabelsSelectorParam(labelSelector).
FieldsSelectorParam(fieldSelector).
Watch() Watch()
} }
......
...@@ -21,7 +21,6 @@ import ( ...@@ -21,7 +21,6 @@ import (
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta" "k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
...@@ -72,7 +71,7 @@ func (r *Selector) Visit(fn VisitorFunc) error { ...@@ -72,7 +71,7 @@ func (r *Selector) Visit(fn VisitorFunc) error {
} }
func (r *Selector) Watch(resourceVersion string) (watch.Interface, error) { func (r *Selector) Watch(resourceVersion string) (watch.Interface, error) {
return NewHelper(r.Client, r.Mapping).Watch(r.Namespace, resourceVersion, r.ResourceMapping().APIVersion, r.Selector, fields.Everything()) return NewHelper(r.Client, r.Mapping).Watch(r.Namespace, resourceVersion, r.ResourceMapping().APIVersion, r.Selector)
} }
// ResourceMapping returns the mapping for this resource and implements ResourceMapping // ResourceMapping returns the mapping for this resource and implements ResourceMapping
......
...@@ -237,18 +237,18 @@ type TestUnknownType struct{} ...@@ -237,18 +237,18 @@ type TestUnknownType struct{}
func (*TestUnknownType) IsAnAPIObject() {} func (*TestUnknownType) IsAnAPIObject() {}
func PrintCustomType(obj *TestPrintType, w io.Writer, withNamespace bool, wide bool, columnLabels []string) error { func PrintCustomType(obj *TestPrintType, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
_, err := fmt.Fprintf(w, "%s", obj.Data) _, err := fmt.Fprintf(w, "%s", obj.Data)
return err return err
} }
func ErrorPrintHandler(obj *TestPrintType, w io.Writer, withNamespace bool, wide bool, columnLabels []string) error { func ErrorPrintHandler(obj *TestPrintType, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
return fmt.Errorf("ErrorPrintHandler error") return fmt.Errorf("ErrorPrintHandler error")
} }
func TestCustomTypePrinting(t *testing.T) { func TestCustomTypePrinting(t *testing.T) {
columns := []string{"Data"} columns := []string{"Data"}
printer := NewHumanReadablePrinter(false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, []string{})
printer.Handler(columns, PrintCustomType) printer.Handler(columns, PrintCustomType)
obj := TestPrintType{"test object"} obj := TestPrintType{"test object"}
...@@ -265,7 +265,7 @@ func TestCustomTypePrinting(t *testing.T) { ...@@ -265,7 +265,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, []string{}) printer := NewHumanReadablePrinter(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{}
...@@ -276,7 +276,7 @@ func TestPrintHandlerError(t *testing.T) { ...@@ -276,7 +276,7 @@ func TestPrintHandlerError(t *testing.T) {
} }
func TestUnknownTypePrinting(t *testing.T) { func TestUnknownTypePrinting(t *testing.T) {
printer := NewHumanReadablePrinter(false, false, false, []string{}) printer := NewHumanReadablePrinter(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 {
...@@ -451,8 +451,8 @@ func TestPrinters(t *testing.T) { ...@@ -451,8 +451,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, []string{}), "humanReadable": NewHumanReadablePrinter(true, false, false, false, []string{}),
"humanReadableHeaders": NewHumanReadablePrinter(false, false, false, []string{}), "humanReadableHeaders": NewHumanReadablePrinter(false, false, false, false, []string{}),
"json": &JSONPrinter{}, "json": &JSONPrinter{},
"yaml": &YAMLPrinter{}, "yaml": &YAMLPrinter{},
"template": templatePrinter, "template": templatePrinter,
...@@ -489,7 +489,7 @@ func TestPrinters(t *testing.T) { ...@@ -489,7 +489,7 @@ func TestPrinters(t *testing.T) {
func TestPrintEventsResultSorted(t *testing.T) { func TestPrintEventsResultSorted(t *testing.T) {
// Arrange // Arrange
printer := NewHumanReadablePrinter(false /* noHeaders */, false, false, []string{}) printer := NewHumanReadablePrinter(false /* noHeaders */, false, false, false, []string{})
obj := api.EventList{ obj := api.EventList{
Items: []api.Event{ Items: []api.Event{
...@@ -530,7 +530,7 @@ func TestPrintEventsResultSorted(t *testing.T) { ...@@ -530,7 +530,7 @@ func TestPrintEventsResultSorted(t *testing.T) {
} }
func TestPrintMinionStatus(t *testing.T) { func TestPrintMinionStatus(t *testing.T) {
printer := NewHumanReadablePrinter(false, false, false, []string{}) printer := NewHumanReadablePrinter(false, false, false, false, []string{})
table := []struct { table := []struct {
minion api.Node minion api.Node
status string status string
...@@ -741,7 +741,7 @@ func TestPrintHumanReadableService(t *testing.T) { ...@@ -741,7 +741,7 @@ func TestPrintHumanReadableService(t *testing.T) {
for _, svc := range tests { for _, svc := range tests {
buff := bytes.Buffer{} buff := bytes.Buffer{}
printService(&svc, &buff, false, false, []string{}) printService(&svc, &buff, 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) {
...@@ -922,7 +922,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) { ...@@ -922,7 +922,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, []string{}) printer := NewHumanReadablePrinter(false, true, 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 {
...@@ -934,7 +934,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) { ...@@ -934,7 +934,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, []string{}) printer := NewHumanReadablePrinter(false, true, 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 {
...@@ -1029,7 +1029,100 @@ func TestPrintPod(t *testing.T) { ...@@ -1029,7 +1029,100 @@ 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, false, false, []string{}) printPod(&test.pod, buf, false, false, true, []string{})
// We ignore time
if !strings.HasPrefix(buf.String(), test.expect) {
t.Fatalf("Expected: %s, got: %s", test.expect, buf.String())
}
buf.Reset()
}
}
func TestPrintNonTerminatedPod(t *testing.T) {
tests := []struct {
pod api.Pod
expect string
}{
{
// Test pod phase Running should be printed
api.Pod{
ObjectMeta: api.ObjectMeta{Name: "test1"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: api.PodRunning,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"test1\t1/2\tRunning\t6\t",
},
{
// Test pod phase Pending should be printed
api.Pod{
ObjectMeta: api.ObjectMeta{Name: "test2"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: api.PodPending,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"test2\t1/2\tPending\t6\t",
},
{
// Test pod phase Unknown should be printed
api.Pod{
ObjectMeta: api.ObjectMeta{Name: "test3"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: api.PodUnknown,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"test3\t1/2\tUnknown\t6\t",
},
{
// Test pod phase Succeeded shouldn't be printed
api.Pod{
ObjectMeta: api.ObjectMeta{Name: "test4"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: api.PodSucceeded,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{RestartCount: 3},
},
},
},
"",
},
{
// Test pod phase Failed shouldn't be printed
api.Pod{
ObjectMeta: api.ObjectMeta{Name: "test5"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: api.PodFailed,
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{Ready: true, RestartCount: 3},
},
},
},
"",
},
}
buf := bytes.NewBuffer([]byte{})
for _, test := range tests {
printPod(&test.pod, buf, 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())
...@@ -1089,7 +1182,7 @@ func TestPrintPodWithLabels(t *testing.T) { ...@@ -1089,7 +1182,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, false, false, test.labelColumns) printPod(&test.pod, buf, 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())
......
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