Commit 7403878a authored by Mike Metral's avatar Mike Metral

allow kubectl cmd to process dirs recursively

reqs: - the kubectl cmd must support the -f | --filename flag - the kubectl cmd must support visiting a dir one level deep, or using more than one resource
parent e01feae7
......@@ -278,6 +278,8 @@ _kubectl_get()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--output-version=")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=")
two_word_flags+=("-l")
flags+=("--show-all")
......@@ -358,6 +360,8 @@ _kubectl_describe()
two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=")
two_word_flags+=("-l")
flags+=("--alsologtostderr")
......@@ -756,6 +760,8 @@ _kubectl_create()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config")
flags+=("--schema-cache-dir=")
flags+=("--validate")
......@@ -812,6 +818,8 @@ _kubectl_replace()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config")
flags+=("--schema-cache-dir=")
flags+=("--timeout=")
......@@ -868,6 +876,8 @@ _kubectl_patch()
flags+=("--patch=")
two_word_flags+=("-p")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--type=")
flags+=("--alsologtostderr")
flags+=("--api-version=")
......@@ -922,6 +932,8 @@ _kubectl_delete()
flags+=("--ignore-not-found")
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=")
two_word_flags+=("-l")
flags+=("--timeout=")
......@@ -998,6 +1010,8 @@ _kubectl_edit()
two_word_flags+=("-o")
flags+=("--output-version=")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config")
flags+=("--windows-line-endings")
flags+=("--alsologtostderr")
......@@ -1048,6 +1062,8 @@ _kubectl_apply()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--schema-cache-dir=")
flags+=("--validate")
flags+=("--alsologtostderr")
......@@ -1259,6 +1275,8 @@ _kubectl_scale()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--replicas=")
flags+=("--resource-version=")
flags+=("--timeout=")
......@@ -1708,6 +1726,8 @@ _kubectl_expose()
flags+=("--port=")
flags+=("--protocol=")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config")
flags+=("--selector=")
flags+=("--session-affinity=")
......@@ -1775,6 +1795,8 @@ _kubectl_autoscale()
two_word_flags+=("-o")
flags+=("--output-version=")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config")
flags+=("--show-all")
flags+=("-a")
......@@ -1828,6 +1850,8 @@ _kubectl_rollout_history()
two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--revision=")
flags+=("--alsologtostderr")
flags+=("--api-version=")
......@@ -1874,6 +1898,8 @@ _kubectl_rollout_pause()
two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--certificate-authority=")
......@@ -1919,6 +1945,8 @@ _kubectl_rollout_resume()
two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--certificate-authority=")
......@@ -1964,6 +1992,8 @@ _kubectl_rollout_undo()
two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--to-revision=")
flags+=("--alsologtostderr")
flags+=("--api-version=")
......@@ -2061,6 +2091,8 @@ _kubectl_label()
flags+=("--output-version=")
flags+=("--overwrite")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--resource-version=")
flags+=("--selector=")
two_word_flags+=("-l")
......@@ -2146,6 +2178,8 @@ _kubectl_annotate()
flags+=("--output-version=")
flags+=("--overwrite")
flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--resource-version=")
flags+=("--selector=")
two_word_flags+=("-l")
......@@ -2738,6 +2772,8 @@ _kubectl_convert()
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--output-version=")
flags+=("--recursive")
flags+=("-R")
flags+=("--schema-cache-dir=")
flags+=("--show-all")
flags+=("-a")
......
......@@ -60,6 +60,10 @@ horizontalpodautoscalers (hpa), resourcequotas (quota) or secrets.
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-resource\-version\fP=""
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.
......
......@@ -34,6 +34,10 @@ JSON and YAML formats are accepted.
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
......
......@@ -68,6 +68,10 @@ An autoscaler can automatically increase or decrease number of pods deployed wit
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-save\-config\fP=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.
......
......@@ -50,6 +50,10 @@ to change to output destination.
Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
......
......@@ -33,6 +33,10 @@ JSON and YAML formats are accepted.
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-save\-config\fP=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.
......
......@@ -53,6 +53,10 @@ will be lost along with the rest of the resource.
Output mode. Use "\-o name" for shorter output (resource/name).
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on.
......
......@@ -40,6 +40,10 @@ componentstatuses (cs), endpoints (ep), and secrets.
Filename, directory, or URL to a file containing the resource to describe
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on
......
......@@ -55,6 +55,10 @@ saved copy to include the latest resource version.
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-save\-config\fP=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.
......
......@@ -92,6 +92,10 @@ labels are specified, the new service will re\-use the labels from the resource
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-save\-config\fP=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.
......
......@@ -59,6 +59,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource(
Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on
......
......@@ -57,6 +57,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-resource\-version\fP=""
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.
......
......@@ -41,6 +41,10 @@ Please refer to the models in
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-type\fP="strategic"
The type of patch being provided; one of [json merge strategic]
......
......@@ -51,6 +51,10 @@ Please refer to the models in
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-save\-config\fP=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.
......
......@@ -22,6 +22,10 @@ View previous rollout revisions and configurations.
Filename, directory, or URL to a file identifying the resource to get from a server.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-revision\fP=0
See the details, including podTemplate of the revision specified
......
......@@ -26,6 +26,10 @@ Currently only deployments support being paused.
\fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
......
......@@ -26,6 +26,10 @@ Currently only deployments support being resumed.
\fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
......
......@@ -22,6 +22,10 @@ Rollback to a previous rollout.
Filename, directory, or URL to a file identifying the resource to get from a server.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-to\-revision\fP=0
The revision to rollback to. Default to 0 (last revision).
......
......@@ -40,6 +40,10 @@ scale is sent to the server.
Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-\-replicas\fP=\-1
The new desired number of replicas. Required.
......
......@@ -46,6 +46,10 @@ If the resource is scalable it will be scaled to 0 before deletion.
Output mode. Use "\-o name" for shorter output (resource/name).
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP
\fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on.
......
......@@ -89,6 +89,7 @@ kubectl annotate pods foo description-
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
--overwrite[=false]: If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
......@@ -128,7 +129,7 @@ kubectl annotate pods foo description-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]()
......
......@@ -64,6 +64,7 @@ cat pod.json | kubectl apply -f -
-f, --filename=[]: Filename, directory, or URL to file that contains the configuration to apply
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
--validate[=true]: If true, use a schema to validate the input before sending it
```
......@@ -99,7 +100,7 @@ cat pod.json | kubectl apply -f -
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_apply.md?pixel)]()
......
......@@ -72,6 +72,7 @@ kubectl autoscale rc foo --max=5 --cpu-percent=80
-o, --output="": 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].
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
......@@ -110,7 +111,7 @@ kubectl autoscale rc foo --max=5 --cpu-percent=80
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 22-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_autoscale.md?pixel)]()
......
......@@ -77,6 +77,7 @@ kubectl convert -f . | kubectl create -f -
--no-headers[=false]: When using the default output, don't print headers.
-o, --output="": 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].
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
-R, --recursive[=false]: If true, process directory recursively.
--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.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column)
......@@ -116,7 +117,7 @@ kubectl convert -f . | kubectl create -f -
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]()
......
......@@ -63,6 +63,7 @@ cat pod.json | kubectl create -f -
-f, --filename=[]: Filename, directory, or URL to file to use to create the resource
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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.
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
--validate[=true]: If true, use a schema to validate the input before sending it
......@@ -103,7 +104,7 @@ cat pod.json | kubectl create -f -
* [kubectl create secret](kubectl_create_secret.md) - Create a secret using specified subcommand.
* [kubectl create serviceaccount](kubectl_create_serviceaccount.md) - Create a service account with the specified name.
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create.md?pixel)]()
......
......@@ -84,6 +84,7 @@ kubectl delete pods --all
--grace-period=-1: Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.
--ignore-not-found[=false]: Treat "resource not found" as a successful delete. Defaults to "true" when --all is specified.
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
-R, --recursive[=false]: If true, process directory recursively.
-l, --selector="": Selector (label query) to filter on.
--timeout=0: The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
```
......@@ -119,7 +120,7 @@ kubectl delete pods --all
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_delete.md?pixel)]()
......
......@@ -86,6 +86,7 @@ kubectl describe pods frontend
```
-f, --filename=[]: Filename, directory, or URL to a file containing the resource to describe
-R, --recursive[=false]: If true, process directory recursively.
-l, --selector="": Selector (label query) to filter on
```
......@@ -120,7 +121,7 @@ kubectl describe pods frontend
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 25-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_describe.md?pixel)]()
......
......@@ -83,6 +83,7 @@ kubectl edit (RESOURCE/NAME | -f FILENAME)
-o, --output="yaml": Output format. One of: yaml|json.
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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.
--windows-line-endings[=false]: Use Windows line-endings (default Unix line-endings)
```
......@@ -118,7 +119,7 @@ kubectl edit (RESOURCE/NAME | -f FILENAME)
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_edit.md?pixel)]()
......
......@@ -95,6 +95,7 @@ kubectl expose deployment nginx --port=80 --target-port=8000
--port="": The port that the service should serve on. Copied from the resource being exposed, if unspecified
--protocol="TCP": The network protocol for the service to be created. Default is 'tcp'.
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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.
--selector="": A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.
--session-affinity="": If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
......@@ -137,7 +138,7 @@ kubectl expose deployment nginx --port=80 --target-port=8000
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 22-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_expose.md?pixel)]()
......
......@@ -92,6 +92,7 @@ kubectl get rc/web service/frontend pods/web-pod-13je7
--no-headers[=false]: When using the default output, don't print headers.
-o, --output="": 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].
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
-R, --recursive[=false]: If true, process directory recursively.
-l, --selector="": Selector (label query) to filter on
-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)
......@@ -132,7 +133,7 @@ kubectl get rc/web service/frontend pods/web-pod-13je7
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 25-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![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-
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
--overwrite[=false]: If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
......@@ -122,7 +123,7 @@ kubectl label pods foo bar-
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_label.md?pixel)]()
......
......@@ -73,6 +73,7 @@ kubectl patch pod valid-pod -type='json' -p='[{"op": "replace", "path": "/spec/c
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
-p, --patch="": The patch to be applied to the resource JSON file.
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--type="strategic": The type of patch being provided; one of [json merge strategic]
```
......@@ -107,7 +108,7 @@ kubectl patch pod valid-pod -type='json' -p='[{"op": "replace", "path": "/spec/c
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_patch.md?pixel)]()
......
......@@ -76,6 +76,7 @@ kubectl replace --force -f ./pod.json
--grace-period=-1: Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative.
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--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.
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
--timeout=0: Only relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object
......@@ -113,7 +114,7 @@ kubectl replace --force -f ./pod.json
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_replace.md?pixel)]()
......
......@@ -59,6 +59,7 @@ kubectl rollout history deployment/abc --revision=3
```
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to get from a server.
-R, --recursive[=false]: If true, process directory recursively.
--revision=0: See the details, including podTemplate of the revision specified
```
......@@ -93,7 +94,7 @@ kubectl rollout history deployment/abc --revision=3
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment
###### Auto generated by spf13/cobra on 21-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_history.md?pixel)]()
......
......@@ -62,6 +62,7 @@ kubectl rollout pause deployment/nginx
```
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to get from a server.
-R, --recursive[=false]: If true, process directory recursively.
```
### Options inherited from parent commands
......@@ -95,7 +96,7 @@ kubectl rollout pause deployment/nginx
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_pause.md?pixel)]()
......
......@@ -60,6 +60,7 @@ kubectl rollout resume deployment/nginx
```
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to get from a server.
-R, --recursive[=false]: If true, process directory recursively.
```
### Options inherited from parent commands
......@@ -93,7 +94,7 @@ kubectl rollout resume deployment/nginx
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment
###### Auto generated by spf13/cobra on 2-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_resume.md?pixel)]()
......
......@@ -59,6 +59,7 @@ kubectl rollout undo deployment/abc --to-revision=3
```
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to get from a server.
-R, --recursive[=false]: If true, process directory recursively.
--to-revision=0: The revision to rollback to. Default to 0 (last revision).
```
......@@ -93,7 +94,7 @@ kubectl rollout undo deployment/abc --to-revision=3
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment
###### Auto generated by spf13/cobra on 21-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_undo.md?pixel)]()
......
......@@ -76,6 +76,7 @@ kubectl scale --replicas=3 job/cron
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to set a new size
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation.
-R, --recursive[=false]: If true, process directory recursively.
--replicas=-1: The new desired number of replicas. Required.
--resource-version="": Precondition for resource version. Requires that the current resource version match this value in order to scale.
--timeout=0: The length of time to wait before giving up on a scale operation, zero means don't wait.
......@@ -112,7 +113,7 @@ kubectl scale --replicas=3 job/cron
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 22-Mar-2016
###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_scale.md?pixel)]()
......
......@@ -52,6 +52,8 @@ type AnnotateOptions struct {
f *cmdutil.Factory
out io.Writer
cmd *cobra.Command
recursive bool
}
const (
......@@ -114,6 +116,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.resourceVersion, "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.")
usage := "Filename, directory, or URL to a file identifying the resource to update the annotation"
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.recursive)
cmdutil.AddRecordFlag(cmd)
return cmd
}
......@@ -162,7 +165,7 @@ func (o *AnnotateOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra
o.builder = resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.filenames...).
FilenameParam(enforceNamespace, o.recursive, o.filenames...).
SelectorParam(o.selector).
ResourceTypeOrNameArgs(o.all, o.resources...).
Flatten().
......
......@@ -35,6 +35,7 @@ import (
// add them here instead of referencing the cmd.Flags()
type ApplyOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -68,6 +69,7 @@ func NewCmdApply(f *cmdutil.Factory, out io.Writer) *cobra.Command {
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddRecordFlag(cmd)
return cmd
......@@ -98,7 +100,7 @@ func RunApply(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *Ap
Schema(schema).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten().
Do()
err = r.Err()
......
......@@ -28,6 +28,13 @@ import (
"github.com/spf13/cobra"
)
// AutoscaleOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
// referencing the cmd.Flags()
type AutoscaleOptions struct {
Filenames []string
Recursive bool
}
const (
autoscaleLong = `Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.
......@@ -42,14 +49,15 @@ kubectl autoscale rc foo --max=5 --cpu-percent=80`
)
func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
filenames := []string{}
options := &AutoscaleOptions{}
cmd := &cobra.Command{
Use: "autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]",
Short: "Auto-scale a Deployment, ReplicaSet, or ReplicationController",
Long: autoscaleLong,
Example: autoscaleExample,
Run: func(cmd *cobra.Command, args []string) {
err := RunAutoscale(f, out, cmd, args, filenames)
err := RunAutoscale(f, out, cmd, args, options)
cmdutil.CheckErr(err)
},
}
......@@ -62,13 +70,14 @@ func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().String("name", "", "The name for the newly created object. If not specified, the name of the input resource will be used.")
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without creating it.")
usage := "Filename, directory, or URL to a file identifying the resource to autoscale."
kubectl.AddJsonFilenameFlag(cmd, &filenames, usage)
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd)
return cmd
}
func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, filenames []string) error {
func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, options *AutoscaleOptions) error {
namespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
......@@ -83,7 +92,7 @@ func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).
Flatten().
Do()
......
......@@ -74,6 +74,7 @@ func NewCmdConvert(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to file to need to get converted."
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.recursive)
cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd)
cmdutil.AddPrinterFlags(cmd)
......@@ -93,6 +94,8 @@ type ConvertOptions struct {
printer kubectl.ResourcePrinter
outputVersion unversioned.GroupVersion
recursive bool
}
// Complete collects information required to run Convert command from command line.
......@@ -125,7 +128,7 @@ func (o *ConvertOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.
}
o.builder = o.builder.NamespaceParam(cmdNamespace).
ContinueOnError().
FilenameParam(false, o.filenames...).
FilenameParam(false, o.recursive, o.filenames...).
Flatten()
// build the printer
......
......@@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags()
type CreateOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -71,6 +72,7 @@ func NewCmdCreate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd)
......@@ -106,7 +108,7 @@ func RunCreate(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *C
Schema(schema).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten().
Do()
err = r.Err()
......
......@@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags()
type DeleteOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -91,6 +92,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
usage := "Filename, directory, or URL to a file containing the resource to delete."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful delete. Defaults to \"true\" when --all is specified.")
......@@ -111,7 +113,7 @@ func RunDelete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(deleteAll).
ResourceTypeOrNameArgs(false, args...).RequireObject(false).
......
......@@ -36,6 +36,7 @@ import (
// referencing the cmd.Flags()
type DescribeOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -86,6 +87,7 @@ func NewCmdDescribe(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
usage := "Filename, directory, or URL to a file containing the resource to describe"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
return cmd
}
......@@ -105,7 +107,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector).
ResourceTypeOrNameArgs(true, args...).
Flatten().
......
......@@ -74,17 +74,25 @@ saved copy to include the latest resource version.`
kubectl edit svc/docker-registry --output-version=v1 -o json`
)
// EditOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
// referencing the cmd.Flags()
type EditOptions struct {
Filenames []string
Recursive bool
}
var errExit = fmt.Errorf("exit directly")
func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
filenames := []string{}
options := &EditOptions{}
cmd := &cobra.Command{
Use: "edit (RESOURCE/NAME | -f FILENAME)",
Short: "Edit a resource on the server",
Long: editLong,
Example: fmt.Sprintf(editExample),
Run: func(cmd *cobra.Command, args []string) {
err := RunEdit(f, out, errOut, cmd, args, filenames)
err := RunEdit(f, out, errOut, cmd, args, options)
if err == errExit {
os.Exit(1)
}
......@@ -92,7 +100,8 @@ func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
},
}
usage := "Filename, directory, or URL to file to use to edit the resource"
kubectl.AddJsonFilenameFlag(cmd, &filenames, usage)
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("output", "o", "yaml", "Output format. One of: yaml|json.")
cmd.Flags().String("output-version", "", "Output the formatted object with the given group version (for ex: 'extensions/v1beta1').")
cmd.Flags().Bool("windows-line-endings", gruntime.GOOS == "windows", "Use Windows line-endings (default Unix line-endings)")
......@@ -101,7 +110,7 @@ func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
return cmd
}
func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args []string, filenames []string) error {
func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args []string, options *EditOptions) error {
var printer kubectl.ResourcePrinter
var ext string
switch format := cmdutil.GetFlagString(cmd, "output"); format {
......@@ -130,7 +139,7 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(true, args...).
Latest().
Flatten().
......
......@@ -34,6 +34,7 @@ import (
// referencing the cmd.Flags()
type ExposeOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -102,6 +103,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to a file identifying the resource to expose a service"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd)
return cmd
......@@ -117,7 +119,7 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).
Flatten().
Do()
......
......@@ -33,6 +33,7 @@ import (
// referencing the cmd.Flags()
type GetOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -100,6 +101,7 @@ func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().Bool("export", false, "If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.")
usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd
}
......@@ -139,7 +141,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
if isWatch || isWatchOnly {
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector).
ExportParam(export).
ResourceTypeOrNameArgs(true, args...).
......@@ -194,7 +196,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector).
ExportParam(export).
ResourceTypeOrNameArgs(true, args...).
......
......@@ -39,6 +39,7 @@ import (
// referencing the cmd.Flags()
type LabelOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -96,6 +97,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().String("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.")
usage := "Filename, directory, or URL to a file identifying the resource to update the labels"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it.")
cmdutil.AddRecordFlag(cmd)
......@@ -203,10 +205,11 @@ func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
return cmdutil.UsageError(cmd, err.Error())
}
mapper, typer := f.Object()
b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector).
ResourceTypeOrNameArgs(all, resources...).
Flatten().
......
......@@ -37,6 +37,7 @@ var patchTypes = map[string]api.PatchType{"json": api.JSONPatchType, "merge": ap
// referencing the cmd.Flags()
type PatchOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -82,6 +83,7 @@ func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to a file identifying the resource to update"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd
}
......@@ -114,7 +116,7 @@ func RunPatch(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).
Flatten().
Do()
......
......@@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags()
type ReplaceOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -82,6 +83,7 @@ func NewCmdReplace(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().Int("grace-period", -1, "Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative.")
cmd.Flags().Duration("timeout", 0, "Only relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object")
cmdutil.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd)
......@@ -117,7 +119,7 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
Schema(schema).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten().
Do()
err = r.Err()
......@@ -184,7 +186,7 @@ func forceReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).RequireObject(false).
Flatten().
Do()
......@@ -209,7 +211,7 @@ func forceReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
Schema(schema).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten().
Do()
err = r.Err()
......
......@@ -201,7 +201,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
request := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
Schema(schema).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, filename).
FilenameParam(enforceNamespace, false, filename).
Do()
obj, err := request.Object()
if err != nil {
......
......@@ -32,6 +32,7 @@ import (
// referencing the cmd.Flags()
type HistoryOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -59,6 +60,7 @@ func NewCmdRolloutHistory(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().Int64("revision", 0, "See the details, including podTemplate of the revision specified")
usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd
}
......@@ -77,7 +79,7 @@ func RunHistory(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []st
infos, err := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(true, args...).
Latest().
Flatten().
......
......@@ -39,6 +39,7 @@ type PauseConfig struct {
Out io.Writer
Filenames []string
Recursive bool
}
const (
......@@ -70,6 +71,7 @@ func NewCmdRolloutPause(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &opts.Recursive)
return cmd
}
......@@ -89,7 +91,7 @@ func (o *PauseConfig) CompletePause(f *cmdutil.Factory, cmd *cobra.Command, out
infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...).
FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...).
SingleResourceType().
Latest().
......
......@@ -39,6 +39,7 @@ type ResumeConfig struct {
Out io.Writer
Filenames []string
Recursive bool
}
const (
......@@ -68,6 +69,7 @@ func NewCmdRolloutResume(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &opts.Recursive)
return cmd
}
......@@ -87,7 +89,7 @@ func (o *ResumeConfig) CompleteResume(f *cmdutil.Factory, cmd *cobra.Command, ou
infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...).
FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...).
SingleResourceType().
Latest().
......
......@@ -37,8 +37,10 @@ type UndoOptions struct {
Typer runtime.ObjectTyper
Info *resource.Info
ToRevision int64
Out io.Writer
Filenames []string
Out io.Writer
Filenames []string
Recursive bool
}
const (
......@@ -67,6 +69,7 @@ func NewCmdRolloutUndo(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().Int64("to-revision", 0, "The revision to rollback to. Default to 0 (last revision).")
usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd
}
......@@ -86,7 +89,7 @@ func (o *UndoOptions) CompleteUndo(f *cmdutil.Factory, cmd *cobra.Command, out i
infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...).
FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...).
Latest().
Flatten().
......
......@@ -34,6 +34,7 @@ import (
// referencing the cmd.Flags()
type ScaleOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -87,6 +88,7 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
usage := "Filename, directory, or URL to a file identifying the resource to set a new size"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd
}
......@@ -110,7 +112,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).
Flatten().
Do()
......
......@@ -30,6 +30,7 @@ import (
// referencing the cmd.Flags()
type StopOptions struct {
Filenames []string
Recursive bool
}
const (
......@@ -69,6 +70,7 @@ func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
usage := "Filename, directory, or URL to file of resource(s) to be stopped."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful stop.")
......@@ -89,7 +91,7 @@ func RunStop(f *cmdutil.Factory, cmd *cobra.Command, args []string, out io.Write
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
ResourceTypeOrNameArgs(false, args...).
FilenameParam(enforceNamespace, options.Filenames...).
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(cmdutil.GetFlagBool(cmd, "all")).
Flatten().
......
......@@ -331,6 +331,10 @@ func AddValidateFlags(cmd *cobra.Command) {
cmd.Flags().String("schema-cache-dir", fmt.Sprintf("~/%s/%s", clientcmd.RecommendedHomeDir, clientcmd.RecommendedSchemaName), fmt.Sprintf("If non-empty, load/store cached API schemas in this directory, default is '$HOME/%s/%s'", clientcmd.RecommendedHomeDir, clientcmd.RecommendedSchemaName))
}
func AddRecursiveFlag(cmd *cobra.Command, value *bool) {
cmd.Flags().BoolVarP(value, "recursive", "R", *value, "If true, process directory recursively.")
}
func AddApplyAnnotationFlags(cmd *cobra.Command) {
cmd.Flags().Bool(ApplyAnnotationsFlag, 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.")
}
......
......@@ -98,7 +98,7 @@ func (b *Builder) Schema(schema validation.Schema) *Builder {
// will cause an error.
// If ContinueOnError() is set prior to this method, objects on the path that are not
// recognized will be ignored (but logged at V(2)).
func (b *Builder) FilenameParam(enforceNamespace bool, paths ...string) *Builder {
func (b *Builder) FilenameParam(enforceNamespace, recursive bool, paths ...string) *Builder {
for _, s := range paths {
switch {
case s == "-":
......@@ -111,7 +111,7 @@ func (b *Builder) FilenameParam(enforceNamespace bool, paths ...string) *Builder
}
b.URL(url)
default:
b.Path(s)
b.Path(recursive, s)
}
}
......@@ -157,7 +157,7 @@ func (b *Builder) Stream(r io.Reader, name string) *Builder {
// FileVisitor is streaming the content to a StreamVisitor. If ContinueOnError() is set
// prior to this method being called, objects on the path that are unrecognized will be
// ignored (but logged at V(2)).
func (b *Builder) Path(paths ...string) *Builder {
func (b *Builder) Path(recursive bool, paths ...string) *Builder {
for _, p := range paths {
_, err := os.Stat(p)
if os.IsNotExist(err) {
......@@ -169,7 +169,7 @@ func (b *Builder) Path(paths ...string) *Builder {
continue
}
visitors, err := ExpandPathsToFileVisitors(b.mapper, p, false, FileExtensions, b.schema)
visitors, err := ExpandPathsToFileVisitors(b.mapper, p, recursive, FileExtensions, b.schema)
if err != nil {
b.errs = append(b.errs, fmt.Errorf("error reading %q: %v", p, err))
}
......
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