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
This commit is contained in:
Mike Metral 2016-03-28 12:44:21 -07:00
parent e01feae75a
commit 7403878ac0
61 changed files with 438 additions and 82 deletions

View File

@ -278,6 +278,8 @@ _kubectl_get()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--show-all") flags+=("--show-all")
@ -358,6 +360,8 @@ _kubectl_describe()
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f") flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml") flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
@ -756,6 +760,8 @@ _kubectl_create()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config") flags+=("--save-config")
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--validate") flags+=("--validate")
@ -812,6 +818,8 @@ _kubectl_replace()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config") flags+=("--save-config")
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--timeout=") flags+=("--timeout=")
@ -868,6 +876,8 @@ _kubectl_patch()
flags+=("--patch=") flags+=("--patch=")
two_word_flags+=("-p") two_word_flags+=("-p")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--type=") flags+=("--type=")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
flags+=("--api-version=") flags+=("--api-version=")
@ -922,6 +932,8 @@ _kubectl_delete()
flags+=("--ignore-not-found") flags+=("--ignore-not-found")
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--recursive")
flags+=("-R")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
flags+=("--timeout=") flags+=("--timeout=")
@ -998,6 +1010,8 @@ _kubectl_edit()
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config") flags+=("--save-config")
flags+=("--windows-line-endings") flags+=("--windows-line-endings")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
@ -1048,6 +1062,8 @@ _kubectl_apply()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--validate") flags+=("--validate")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
@ -1259,6 +1275,8 @@ _kubectl_scale()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--replicas=") flags+=("--replicas=")
flags+=("--resource-version=") flags+=("--resource-version=")
flags+=("--timeout=") flags+=("--timeout=")
@ -1708,6 +1726,8 @@ _kubectl_expose()
flags+=("--port=") flags+=("--port=")
flags+=("--protocol=") flags+=("--protocol=")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config") flags+=("--save-config")
flags+=("--selector=") flags+=("--selector=")
flags+=("--session-affinity=") flags+=("--session-affinity=")
@ -1775,6 +1795,8 @@ _kubectl_autoscale()
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--save-config") flags+=("--save-config")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")
@ -1828,6 +1850,8 @@ _kubectl_rollout_history()
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f") flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml") flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--revision=") flags+=("--revision=")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
flags+=("--api-version=") flags+=("--api-version=")
@ -1874,6 +1898,8 @@ _kubectl_rollout_pause()
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f") flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml") flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
flags+=("--api-version=") flags+=("--api-version=")
flags+=("--certificate-authority=") flags+=("--certificate-authority=")
@ -1919,6 +1945,8 @@ _kubectl_rollout_resume()
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f") flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml") flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
flags+=("--api-version=") flags+=("--api-version=")
flags+=("--certificate-authority=") flags+=("--certificate-authority=")
@ -1964,6 +1992,8 @@ _kubectl_rollout_undo()
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f") flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml") flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--recursive")
flags+=("-R")
flags+=("--to-revision=") flags+=("--to-revision=")
flags+=("--alsologtostderr") flags+=("--alsologtostderr")
flags+=("--api-version=") flags+=("--api-version=")
@ -2061,6 +2091,8 @@ _kubectl_label()
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--overwrite") flags+=("--overwrite")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--resource-version=") flags+=("--resource-version=")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
@ -2146,6 +2178,8 @@ _kubectl_annotate()
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--overwrite") flags+=("--overwrite")
flags+=("--record") flags+=("--record")
flags+=("--recursive")
flags+=("-R")
flags+=("--resource-version=") flags+=("--resource-version=")
flags+=("--selector=") flags+=("--selector=")
two_word_flags+=("-l") two_word_flags+=("-l")
@ -2738,6 +2772,8 @@ _kubectl_convert()
flags+=("--output=") flags+=("--output=")
two_word_flags+=("-o") two_word_flags+=("-o")
flags+=("--output-version=") flags+=("--output-version=")
flags+=("--recursive")
flags+=("-R")
flags+=("--schema-cache-dir=") flags+=("--schema-cache-dir=")
flags+=("--show-all") flags+=("--show-all")
flags+=("-a") flags+=("-a")

View File

@ -59,6 +59,10 @@ horizontalpodautoscalers (hpa), resourcequotas (quota) or secrets.
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-resource\-version\fP="" \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. 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.

View File

@ -33,6 +33,10 @@ JSON and YAML formats are accepted.
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema" \fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema' If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'

View File

@ -67,6 +67,10 @@ An autoscaler can automatically increase or decrease number of pods deployed wit
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-save\-config\fP=false \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. 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.

View File

@ -49,6 +49,10 @@ to change to output destination.
\fB\-\-output\-version\fP="" \fB\-\-output\-version\fP=""
Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). 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 .PP
\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema" \fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema' If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'

View File

@ -32,6 +32,10 @@ JSON and YAML formats are accepted.
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-save\-config\fP=false \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. 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.

View File

@ -52,6 +52,10 @@ will be lost along with the rest of the resource.
\fB\-o\fP, \fB\-\-output\fP="" \fB\-o\fP, \fB\-\-output\fP=""
Output mode. Use "\-o name" for shorter output (resource/name). Output mode. Use "\-o name" for shorter output (resource/name).
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-l\fP, \fB\-\-selector\fP="" \fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on. Selector (label query) to filter on.

View File

@ -39,6 +39,10 @@ componentstatuses (cs), endpoints (ep), and secrets.
\fB\-f\fP, \fB\-\-filename\fP=[] \fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file containing the resource to describe 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 .PP
\fB\-l\fP, \fB\-\-selector\fP="" \fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on Selector (label query) to filter on

View File

@ -54,6 +54,10 @@ saved copy to include the latest resource version.
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-save\-config\fP=false \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. 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.

View File

@ -91,6 +91,10 @@ labels are specified, the new service will re\-use the labels from the resource
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-save\-config\fP=false \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. 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.

View File

@ -58,6 +58,10 @@ of the \-\-template flag, you can filter the attributes of the fetched resource(
\fB\-\-output\-version\fP="" \fB\-\-output\-version\fP=""
Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). 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 .PP
\fB\-l\fP, \fB\-\-selector\fP="" \fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on Selector (label query) to filter on

View File

@ -56,6 +56,10 @@ If \-\-resource\-version is specified, then updates will use this resource versi
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-resource\-version\fP="" \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. 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.

View File

@ -40,6 +40,10 @@ Please refer to the models in
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-type\fP="strategic" \fB\-\-type\fP="strategic"
The type of patch being provided; one of [json merge strategic] The type of patch being provided; one of [json merge strategic]

View File

@ -50,6 +50,10 @@ Please refer to the models in
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-save\-config\fP=false \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. 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.

View File

@ -21,6 +21,10 @@ View previous rollout revisions and configurations.
\fB\-f\fP, \fB\-\-filename\fP=[] \fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server. 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 .PP
\fB\-\-revision\fP=0 \fB\-\-revision\fP=0
See the details, including podTemplate of the revision specified See the details, including podTemplate of the revision specified

View File

@ -26,6 +26,10 @@ Currently only deployments support being paused.
\fB\-f\fP, \fB\-\-filename\fP=[] \fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server. 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 .SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP .PP

View File

@ -26,6 +26,10 @@ Currently only deployments support being resumed.
\fB\-f\fP, \fB\-\-filename\fP=[] \fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server. 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 .SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP .PP

View File

@ -21,6 +21,10 @@ Rollback to a previous rollout.
\fB\-f\fP, \fB\-\-filename\fP=[] \fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the resource to get from a server. 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 .PP
\fB\-\-to\-revision\fP=0 \fB\-\-to\-revision\fP=0
The revision to rollback to. Default to 0 (last revision). The revision to rollback to. Default to 0 (last revision).

View File

@ -39,6 +39,10 @@ scale is sent to the server.
\fB\-\-record\fP=false \fB\-\-record\fP=false
Record current kubectl command in the resource annotation. Record current kubectl command in the resource annotation.
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-\-replicas\fP=\-1 \fB\-\-replicas\fP=\-1
The new desired number of replicas. Required. The new desired number of replicas. Required.

View File

@ -45,6 +45,10 @@ If the resource is scalable it will be scaled to 0 before deletion.
\fB\-o\fP, \fB\-\-output\fP="" \fB\-o\fP, \fB\-\-output\fP=""
Output mode. Use "\-o name" for shorter output (resource/name). Output mode. Use "\-o name" for shorter output (resource/name).
.PP
\fB\-R\fP, \fB\-\-recursive\fP=false
If true, process directory recursively.
.PP .PP
\fB\-l\fP, \fB\-\-selector\fP="" \fB\-l\fP, \fB\-\-selector\fP=""
Selector (label query) to filter on. Selector (label query) to filter on.

View File

@ -89,6 +89,7 @@ kubectl annotate pods foo description-
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). --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. --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. --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. --resource-version="": If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
-l, --selector="": Selector (label query) to filter on -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
@ -128,7 +129,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 on 2-Mar-2016 ###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- 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)]()

View File

@ -64,6 +64,7 @@ cat pod.json | kubectl apply -f -
-f, --filename=[]: Filename, directory, or URL to file that contains the configuration to apply -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). -o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation. --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' --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 --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_apply.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_apply.md?pixel)]()

View File

@ -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]. -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'). --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. --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. --save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column) --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_autoscale.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_autoscale.md?pixel)]()

View File

@ -77,6 +77,7 @@ kubectl convert -f . | kubectl create -f -
--no-headers[=false]: When using the default output, don't print headers. --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]. -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'). --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' --schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column) --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]()

View File

@ -63,6 +63,7 @@ cat pod.json | kubectl create -f -
-f, --filename=[]: Filename, directory, or URL to file to use to create the resource -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). -o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation. --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. --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' --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 --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 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. * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create.md?pixel)]()

View File

@ -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. --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. --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). -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. -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 --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_delete.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_delete.md?pixel)]()

View File

@ -86,6 +86,7 @@ kubectl describe pods frontend
``` ```
-f, --filename=[]: Filename, directory, or URL to a file containing the resource to describe -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 -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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_describe.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_describe.md?pixel)]()

View File

@ -83,6 +83,7 @@ kubectl edit (RESOURCE/NAME | -f FILENAME)
-o, --output="yaml": Output format. One of: yaml|json. -o, --output="yaml": Output format. One of: yaml|json.
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). --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. --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. --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) --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_edit.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_edit.md?pixel)]()

View File

@ -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 --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'. --protocol="TCP": The network protocol for the service to be created. Default is 'tcp'.
--record[=false]: Record current kubectl command in the resource annotation. --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. --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. --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' --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 * [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 --> <!-- 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)]()

View File

@ -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. --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]. -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'). --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 -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
--show-labels[=false]: When printing, show all labels as the last column (default hide labels column) --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 * [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 --> <!-- 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)]()

View File

@ -83,6 +83,7 @@ kubectl label pods foo bar-
--output-version="": Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). --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. --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. --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. --resource-version="": If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
-l, --selector="": Selector (label query) to filter on -l, --selector="": Selector (label query) to filter on
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
@ -122,7 +123,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 on 2-Mar-2016 ###### Auto generated by spf13/cobra on 28-Mar-2016
<!-- 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)]()

View File

@ -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). -o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
-p, --patch="": The patch to be applied to the resource JSON file. -p, --patch="": The patch to be applied to the resource JSON file.
--record[=false]: Record current kubectl command in the resource annotation. --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] --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_patch.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_patch.md?pixel)]()

View File

@ -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. --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). -o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation. --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. --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' --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 --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_replace.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_replace.md?pixel)]()

View File

@ -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. -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 --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_history.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_history.md?pixel)]()

View File

@ -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. -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 ### Options inherited from parent commands
@ -95,7 +96,7 @@ kubectl rollout pause deployment/nginx
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_pause.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_pause.md?pixel)]()

View File

@ -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. -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 ### Options inherited from parent commands
@ -93,7 +94,7 @@ kubectl rollout resume deployment/nginx
* [kubectl rollout](kubectl_rollout.md) - rollout manages a deployment * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_resume.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_resume.md?pixel)]()

View File

@ -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. -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). --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_undo.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rollout_undo.md?pixel)]()

View File

@ -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 -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). -o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--record[=false]: Record current kubectl command in the resource annotation. --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. --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. --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. --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 * [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 --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_scale.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_scale.md?pixel)]()

View File

@ -52,6 +52,8 @@ type AnnotateOptions struct {
f *cmdutil.Factory f *cmdutil.Factory
out io.Writer out io.Writer
cmd *cobra.Command cmd *cobra.Command
recursive bool
} }
const ( 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.") 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" usage := "Filename, directory, or URL to a file identifying the resource to update the annotation"
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.recursive)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
return 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)). o.builder = resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(namespace).DefaultNamespace(). NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.filenames...). FilenameParam(enforceNamespace, o.recursive, o.filenames...).
SelectorParam(o.selector). SelectorParam(o.selector).
ResourceTypeOrNameArgs(o.all, o.resources...). ResourceTypeOrNameArgs(o.all, o.resources...).
Flatten(). Flatten().

View File

@ -35,6 +35,7 @@ import (
// add them here instead of referencing the cmd.Flags() // add them here instead of referencing the cmd.Flags()
type ApplyOptions struct { type ApplyOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( const (
@ -68,6 +69,7 @@ func NewCmdApply(f *cmdutil.Factory, out io.Writer) *cobra.Command {
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmd.MarkFlagRequired("filename") cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd) cmdutil.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd) cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
return cmd return cmd
@ -98,7 +100,7 @@ func RunApply(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *Ap
Schema(schema). Schema(schema).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten(). Flatten().
Do() Do()
err = r.Err() err = r.Err()

View File

@ -28,6 +28,13 @@ import (
"github.com/spf13/cobra" "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 ( const (
autoscaleLong = `Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster. 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 { func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
filenames := []string{} options := &AutoscaleOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]", Use: "autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]",
Short: "Auto-scale a Deployment, ReplicaSet, or ReplicationController", Short: "Auto-scale a Deployment, ReplicaSet, or ReplicationController",
Long: autoscaleLong, Long: autoscaleLong,
Example: autoscaleExample, Example: autoscaleExample,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
err := RunAutoscale(f, out, cmd, args, filenames) err := RunAutoscale(f, out, cmd, args, options)
cmdutil.CheckErr(err) 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().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.") 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." 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.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
return 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() namespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil { if err != nil {
return err 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(namespace).DefaultNamespace(). NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...). ResourceTypeOrNameArgs(false, args...).
Flatten(). Flatten().
Do() Do()

View File

@ -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." usage := "Filename, directory, or URL to file to need to get converted."
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.recursive)
cmd.MarkFlagRequired("filename") cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd) cmdutil.AddValidateFlags(cmd)
cmdutil.AddPrinterFlags(cmd) cmdutil.AddPrinterFlags(cmd)
@ -93,6 +94,8 @@ type ConvertOptions struct {
printer kubectl.ResourcePrinter printer kubectl.ResourcePrinter
outputVersion unversioned.GroupVersion outputVersion unversioned.GroupVersion
recursive bool
} }
// Complete collects information required to run Convert command from command line. // 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). o.builder = o.builder.NamespaceParam(cmdNamespace).
ContinueOnError(). ContinueOnError().
FilenameParam(false, o.filenames...). FilenameParam(false, o.recursive, o.filenames...).
Flatten() Flatten()
// build the printer // build the printer

View File

@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type CreateOptions struct { type CreateOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( const (
@ -71,6 +72,7 @@ func NewCmdCreate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmd.MarkFlagRequired("filename") cmd.MarkFlagRequired("filename")
cmdutil.AddValidateFlags(cmd) cmdutil.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd) cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddApplyAnnotationFlags(cmd) cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
@ -106,7 +108,7 @@ func RunCreate(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *C
Schema(schema). Schema(schema).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten(). Flatten().
Do() Do()
err = r.Err() err = r.Err()

View File

@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type DeleteOptions struct { type DeleteOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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." usage := "Filename, directory, or URL to a file containing the resource to delete."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.") 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("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.") 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")). SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(deleteAll). SelectAllParam(deleteAll).
ResourceTypeOrNameArgs(false, args...).RequireObject(false). ResourceTypeOrNameArgs(false, args...).RequireObject(false).

View File

@ -36,6 +36,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type DescribeOptions struct { type DescribeOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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" usage := "Filename, directory, or URL to a file containing the resource to describe"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on") cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
return cmd 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector). SelectorParam(selector).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
Flatten(). Flatten().

View File

@ -74,17 +74,25 @@ saved copy to include the latest resource version.`
kubectl edit svc/docker-registry --output-version=v1 -o json` 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") var errExit = fmt.Errorf("exit directly")
func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command { func NewCmdEdit(f *cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
filenames := []string{} options := &EditOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "edit (RESOURCE/NAME | -f FILENAME)", Use: "edit (RESOURCE/NAME | -f FILENAME)",
Short: "Edit a resource on the server", Short: "Edit a resource on the server",
Long: editLong, Long: editLong,
Example: fmt.Sprintf(editExample), Example: fmt.Sprintf(editExample),
Run: func(cmd *cobra.Command, args []string) { 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 { if err == errExit {
os.Exit(1) 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" 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().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().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)") 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 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 printer kubectl.ResourcePrinter
var ext string var ext string
switch format := cmdutil.GetFlagString(cmd, "output"); format { 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
Latest(). Latest().
Flatten(). Flatten().

View File

@ -34,6 +34,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type ExposeOptions struct { type ExposeOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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" usage := "Filename, directory, or URL to a file identifying the resource to expose a service"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddApplyAnnotationFlags(cmd) cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
return 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(namespace).DefaultNamespace(). NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...). ResourceTypeOrNameArgs(false, args...).
Flatten(). Flatten().
Do() Do()

View File

@ -33,6 +33,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type GetOptions struct { type GetOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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.") 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." usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd return cmd
} }
@ -139,7 +141,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
if isWatch || isWatchOnly { if isWatch || isWatchOnly {
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces). NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector). SelectorParam(selector).
ExportParam(export). ExportParam(export).
ResourceTypeOrNameArgs(true, args...). 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)). b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces). NamespaceParam(cmdNamespace).DefaultNamespace().AllNamespaces(allNamespaces).
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector). SelectorParam(selector).
ExportParam(export). ExportParam(export).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).

View File

@ -39,6 +39,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type LabelOptions struct { type LabelOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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.") 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" usage := "Filename, directory, or URL to a file identifying the resource to update the labels"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) 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.") cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it.")
cmdutil.AddRecordFlag(cmd) 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()) return cmdutil.UsageError(cmd, err.Error())
} }
mapper, typer := f.Object() mapper, typer := f.Object()
b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)). b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(selector). SelectorParam(selector).
ResourceTypeOrNameArgs(all, resources...). ResourceTypeOrNameArgs(all, resources...).
Flatten(). Flatten().

View File

@ -37,6 +37,7 @@ var patchTypes = map[string]api.PatchType{"json": api.JSONPatchType, "merge": ap
// referencing the cmd.Flags() // referencing the cmd.Flags()
type PatchOptions struct { type PatchOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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" usage := "Filename, directory, or URL to a file identifying the resource to update"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...). ResourceTypeOrNameArgs(false, args...).
Flatten(). Flatten().
Do() Do()

View File

@ -35,6 +35,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type ReplaceOptions struct { type ReplaceOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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().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") 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.AddValidateFlags(cmd)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmdutil.AddOutputFlagsForMutation(cmd) cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddApplyAnnotationFlags(cmd) cmdutil.AddApplyAnnotationFlags(cmd)
cmdutil.AddRecordFlag(cmd) cmdutil.AddRecordFlag(cmd)
@ -117,7 +119,7 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
Schema(schema). Schema(schema).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten(). Flatten().
Do() Do()
err = r.Err() 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...).RequireObject(false). ResourceTypeOrNameArgs(false, args...).RequireObject(false).
Flatten(). Flatten().
Do() Do()
@ -209,7 +211,7 @@ func forceReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
Schema(schema). Schema(schema).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
Flatten(). Flatten().
Do() Do()
err = r.Err() err = r.Err()

View File

@ -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)). request := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
Schema(schema). Schema(schema).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, filename). FilenameParam(enforceNamespace, false, filename).
Do() Do()
obj, err := request.Object() obj, err := request.Object()
if err != nil { if err != nil {

View File

@ -32,6 +32,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type HistoryOptions struct { type HistoryOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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") 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." usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd 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)). infos, err := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
Latest(). Latest().
Flatten(). Flatten().

View File

@ -39,6 +39,7 @@ type PauseConfig struct {
Out io.Writer Out io.Writer
Filenames []string Filenames []string
Recursive bool
} }
const ( 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." usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &opts.Recursive)
return cmd 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)). infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...). FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
SingleResourceType(). SingleResourceType().
Latest(). Latest().

View File

@ -39,6 +39,7 @@ type ResumeConfig struct {
Out io.Writer Out io.Writer
Filenames []string Filenames []string
Recursive bool
} }
const ( 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." usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &opts.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &opts.Recursive)
return cmd 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)). infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...). FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
SingleResourceType(). SingleResourceType().
Latest(). Latest().

View File

@ -37,8 +37,10 @@ type UndoOptions struct {
Typer runtime.ObjectTyper Typer runtime.ObjectTyper
Info *resource.Info Info *resource.Info
ToRevision int64 ToRevision int64
Out io.Writer
Filenames []string Out io.Writer
Filenames []string
Recursive bool
} }
const ( 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).") 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." usage := "Filename, directory, or URL to a file identifying the resource to get from a server."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd 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)). infos, err := resource.NewBuilder(o.Mapper, o.Typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.Filenames...). FilenameParam(enforceNamespace, o.Recursive, o.Filenames...).
ResourceTypeOrNameArgs(true, args...). ResourceTypeOrNameArgs(true, args...).
Latest(). Latest().
Flatten(). Flatten().

View File

@ -34,6 +34,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type ScaleOptions struct { type ScaleOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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" usage := "Filename, directory, or URL to a file identifying the resource to set a new size"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
return cmd 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)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(false, args...). ResourceTypeOrNameArgs(false, args...).
Flatten(). Flatten().
Do() Do()

View File

@ -30,6 +30,7 @@ import (
// referencing the cmd.Flags() // referencing the cmd.Flags()
type StopOptions struct { type StopOptions struct {
Filenames []string Filenames []string
Recursive bool
} }
const ( 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." usage := "Filename, directory, or URL to file of resource(s) to be stopped."
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage) kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.") 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("all", false, "[-all] to select all the specified resources.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful stop.") 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(). ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace(). NamespaceParam(cmdNamespace).DefaultNamespace().
ResourceTypeOrNameArgs(false, args...). ResourceTypeOrNameArgs(false, args...).
FilenameParam(enforceNamespace, options.Filenames...). FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")). SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(cmdutil.GetFlagBool(cmd, "all")). SelectAllParam(cmdutil.GetFlagBool(cmd, "all")).
Flatten(). Flatten().

View File

@ -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)) 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) { 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.") 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.")
} }

View File

@ -98,7 +98,7 @@ func (b *Builder) Schema(schema validation.Schema) *Builder {
// will cause an error. // will cause an error.
// If ContinueOnError() is set prior to this method, objects on the path that are not // If ContinueOnError() is set prior to this method, objects on the path that are not
// recognized will be ignored (but logged at V(2)). // 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 { for _, s := range paths {
switch { switch {
case s == "-": case s == "-":
@ -111,7 +111,7 @@ func (b *Builder) FilenameParam(enforceNamespace bool, paths ...string) *Builder
} }
b.URL(url) b.URL(url)
default: 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 // 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 // prior to this method being called, objects on the path that are unrecognized will be
// ignored (but logged at V(2)). // 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 { for _, p := range paths {
_, err := os.Stat(p) _, err := os.Stat(p)
if os.IsNotExist(err) { if os.IsNotExist(err) {
@ -169,7 +169,7 @@ func (b *Builder) Path(paths ...string) *Builder {
continue continue
} }
visitors, err := ExpandPathsToFileVisitors(b.mapper, p, false, FileExtensions, b.schema) visitors, err := ExpandPathsToFileVisitors(b.mapper, p, recursive, FileExtensions, b.schema)
if err != nil { if err != nil {
b.errs = append(b.errs, fmt.Errorf("error reading %q: %v", p, err)) b.errs = append(b.errs, fmt.Errorf("error reading %q: %v", p, err))
} }

View File

@ -23,7 +23,9 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os"
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
@ -38,6 +40,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/fake" "k8s.io/kubernetes/pkg/client/unversioned/fake"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
utilerrors "k8s.io/kubernetes/pkg/util/errors" utilerrors "k8s.io/kubernetes/pkg/util/errors"
utiltesting "k8s.io/kubernetes/pkg/util/testing"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
watchjson "k8s.io/kubernetes/pkg/watch/json" watchjson "k8s.io/kubernetes/pkg/watch/json"
) )
@ -178,9 +181,74 @@ func (v *testVisitor) Objects() []runtime.Object {
return objects return objects
} }
var aPod string = `
{
"kind": "Pod",
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
"metadata": {
"name": "busybox{id}",
"labels": {
"name": "busybox{id}"
}
},
"spec": {
"containers": [
{
"name": "busybox",
"image": "busybox",
"command": [
"sleep",
"3600"
],
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always"
}
}
`
var aRC string = `
{
"kind": "ReplicationController",
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
"metadata": {
"name": "busybox{id}",
"labels": {
"app": "busybox"
}
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"name": "busybox{id}",
"labels": {
"app": "busybox{id}"
}
},
"spec": {
"containers": [
{
"name": "busybox",
"image": "busybox",
"command": [
"sleep",
"3600"
],
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always"
}
}
}
}
`
func TestPathBuilderAndVersionedObjectNotDefaulted(t *testing.T) { func TestPathBuilderAndVersionedObjectNotDefaulted(t *testing.T) {
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, "../../../docs/user-guide/update-demo/kitten-rc.yaml") FilenameParam(false, false, "../../../docs/user-guide/update-demo/kitten-rc.yaml")
test := &testVisitor{} test := &testVisitor{}
singular := false singular := false
@ -233,33 +301,131 @@ func TestNodeBuilder(t *testing.T) {
} }
} }
func createTestDir(t *testing.T, path string) {
if err := os.MkdirAll(path, 0750); err != nil {
t.Fatalf("error creating test dir: %v", err)
}
}
func writeTestFile(t *testing.T, path string, contents string) {
if err := ioutil.WriteFile(path, []byte(contents), 0644); err != nil {
t.Fatalf("error creating test file %#v", err)
}
}
func TestPathBuilderWithMultiple(t *testing.T) { func TestPathBuilderWithMultiple(t *testing.T) {
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). // create test dirs
FilenameParam(false, "../../../examples/guestbook/redis-master-controller.yaml"). tmpDir, err := utiltesting.MkTmpdir("recursive_test_multiple")
FilenameParam(false, "../../../examples/pod"). if err != nil {
NamespaceParam("test").DefaultNamespace() t.Fatalf("error creating temp dir: %v", err)
}
createTestDir(t, fmt.Sprintf("%s/%s", tmpDir, "recursive/pod/pod_1"))
createTestDir(t, fmt.Sprintf("%s/%s", tmpDir, "recursive/rc/rc_1"))
createTestDir(t, fmt.Sprintf("%s/%s", tmpDir, "inode/hardlink"))
defer os.RemoveAll(tmpDir)
test := &testVisitor{} // create test files
singular := false writeTestFile(t, fmt.Sprintf("%s/recursive/pod/busybox.json", tmpDir), strings.Replace(aPod, "{id}", "0", -1))
writeTestFile(t, fmt.Sprintf("%s/recursive/pod/pod_1/busybox.json", tmpDir), strings.Replace(aPod, "{id}", "1", -1))
err := b.Do().IntoSingular(&singular).Visit(test.Handle) writeTestFile(t, fmt.Sprintf("%s/recursive/rc/busybox.json", tmpDir), strings.Replace(aRC, "{id}", "0", -1))
if err != nil || singular || len(test.Infos) != 2 { writeTestFile(t, fmt.Sprintf("%s/recursive/rc/rc_1/busybox.json", tmpDir), strings.Replace(aRC, "{id}", "1", -1))
t.Fatalf("unexpected response: %v %t %#v", err, singular, test.Infos) writeTestFile(t, fmt.Sprintf("%s/inode/hardlink/busybox.json", tmpDir), strings.Replace(aPod, "{id}", "0", -1))
if err := os.Link(fmt.Sprintf("%s/inode/hardlink/busybox.json", tmpDir), fmt.Sprintf("%s/inode/hardlink/busybox-link.json", tmpDir)); err != nil {
t.Fatalf("error creating test file: %v", err)
} }
info := test.Infos[0] tests := []struct {
if _, ok := info.Object.(*api.ReplicationController); !ok || info.Name != "redis-master" || info.Namespace != "test" { name string
t.Errorf("unexpected info: %#v", info) object runtime.Object
recursive bool
directory string
expectedNames []string
}{
{"pod", &api.Pod{}, false, "../../../examples/pod", []string{"nginx"}},
{"recursive-pod", &api.Pod{}, true, fmt.Sprintf("%s/recursive/pod", tmpDir), []string{"busybox0", "busybox1"}},
{"rc", &api.ReplicationController{}, false, "../../../examples/guestbook/redis-master-controller.yaml", []string{"redis-master"}},
{"recursive-rc", &api.ReplicationController{}, true, fmt.Sprintf("%s/recursive/rc", tmpDir), []string{"busybox0", "busybox1"}},
{"hardlink", &api.Pod{}, false, fmt.Sprintf("%s/inode/hardlink/busybox-link.json", tmpDir), []string{"busybox0"}},
{"hardlink", &api.Pod{}, true, fmt.Sprintf("%s/inode/hardlink/busybox-link.json", tmpDir), []string{"busybox0"}},
} }
info = test.Infos[1]
if _, ok := info.Object.(*api.Pod); !ok || info.Name != "nginx" || info.Namespace != "test" { for _, test := range tests {
t.Errorf("unexpected info: %#v", info) b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, test.recursive, test.directory).
NamespaceParam("test").DefaultNamespace()
testVisitor := &testVisitor{}
singular := false
err := b.Do().IntoSingular(&singular).Visit(testVisitor.Handle)
if err != nil {
t.Fatalf("unexpected response: %v %t %#v %s", err, singular, testVisitor.Infos, test.name)
}
info := testVisitor.Infos
for i, v := range info {
switch test.object.(type) {
case *api.Pod:
if _, ok := v.Object.(*api.Pod); !ok || v.Name != test.expectedNames[i] || v.Namespace != "test" {
t.Errorf("unexpected info: %#v", v)
}
case *api.ReplicationController:
if _, ok := v.Object.(*api.ReplicationController); !ok || v.Name != test.expectedNames[i] || v.Namespace != "test" {
t.Errorf("unexpected info: %#v", v)
}
}
}
}
}
func TestPathBuilderWithMultipleInvalid(t *testing.T) {
// create test dirs
tmpDir, err := utiltesting.MkTmpdir("recursive_test_multiple_invalid")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
}
createTestDir(t, fmt.Sprintf("%s/%s", tmpDir, "inode/symlink/pod"))
defer os.RemoveAll(tmpDir)
// create test files
writeTestFile(t, fmt.Sprintf("%s/inode/symlink/pod/busybox.json", tmpDir), strings.Replace(aPod, "{id}", "0", -1))
if err := os.Symlink(fmt.Sprintf("%s/inode/symlink/pod", tmpDir), fmt.Sprintf("%s/inode/symlink/pod-link", tmpDir)); err != nil {
t.Fatalf("error creating test file: %v", err)
}
if err := os.Symlink(fmt.Sprintf("%s/inode/symlink/loop", tmpDir), fmt.Sprintf("%s/inode/symlink/loop", tmpDir)); err != nil {
t.Fatalf("error creating test file: %v", err)
}
tests := []struct {
name string
recursive bool
directory string
}{
{"symlink", false, fmt.Sprintf("%s/inode/symlink/pod-link", tmpDir)},
{"symlink", true, fmt.Sprintf("%s/inode/symlink/pod-link", tmpDir)},
{"loop", false, fmt.Sprintf("%s/inode/symlink/loop", tmpDir)},
{"loop", true, fmt.Sprintf("%s/inode/symlink/loop", tmpDir)},
}
for _, test := range tests {
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, test.recursive, test.directory).
NamespaceParam("test").DefaultNamespace()
testVisitor := &testVisitor{}
singular := false
err := b.Do().IntoSingular(&singular).Visit(testVisitor.Handle)
if err == nil {
t.Fatalf("unexpected response: %v %t %#v %s", err, singular, testVisitor.Infos, test.name)
}
} }
} }
func TestDirectoryBuilder(t *testing.T) { func TestDirectoryBuilder(t *testing.T) {
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, "../../../examples/guestbook"). FilenameParam(false, false, "../../../examples/guestbook").
NamespaceParam("test").DefaultNamespace() NamespaceParam("test").DefaultNamespace()
test := &testVisitor{} test := &testVisitor{}
@ -290,7 +456,7 @@ func TestNamespaceOverride(t *testing.T) {
// defer s.Close() // defer s.Close()
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, s.URL). FilenameParam(false, false, s.URL).
NamespaceParam("test") NamespaceParam("test")
test := &testVisitor{} test := &testVisitor{}
@ -301,7 +467,7 @@ func TestNamespaceOverride(t *testing.T) {
} }
b = NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b = NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(true, s.URL). FilenameParam(true, false, s.URL).
NamespaceParam("test") NamespaceParam("test")
test = &testVisitor{} test = &testVisitor{}
@ -322,7 +488,7 @@ func TestURLBuilder(t *testing.T) {
// defer s.Close() // defer s.Close()
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, s.URL). FilenameParam(false, false, s.URL).
NamespaceParam("foo") NamespaceParam("foo")
test := &testVisitor{} test := &testVisitor{}
@ -352,7 +518,7 @@ func TestURLBuilderRequireNamespace(t *testing.T) {
// defer s.Close() // defer s.Close()
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
FilenameParam(false, s.URL). FilenameParam(false, false, s.URL).
NamespaceParam("test").RequireNamespace() NamespaceParam("test").RequireNamespace()
test := &testVisitor{} test := &testVisitor{}
@ -750,7 +916,7 @@ func TestContinueOnErrorVisitor(t *testing.T) {
func TestSingularObject(t *testing.T) { func TestSingularObject(t *testing.T) {
obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
NamespaceParam("test").DefaultNamespace(). NamespaceParam("test").DefaultNamespace().
FilenameParam(false, "../../../examples/guestbook/redis-master-controller.yaml"). FilenameParam(false, false, "../../../examples/guestbook/redis-master-controller.yaml").
Flatten(). Flatten().
Do().Object() Do().Object()
@ -770,7 +936,7 @@ func TestSingularObject(t *testing.T) {
func TestSingularObjectNoExtension(t *testing.T) { func TestSingularObjectNoExtension(t *testing.T) {
obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
NamespaceParam("test").DefaultNamespace(). NamespaceParam("test").DefaultNamespace().
FilenameParam(false, "../../../examples/pod"). FilenameParam(false, false, "../../../examples/pod").
Flatten(). Flatten().
Do().Object() Do().Object()
@ -881,7 +1047,7 @@ func TestWatch(t *testing.T) {
}), }),
}), testapi.Default.Codec()). }), testapi.Default.Codec()).
NamespaceParam("test").DefaultNamespace(). NamespaceParam("test").DefaultNamespace().
FilenameParam(false, "../../../examples/guestbook/redis-master-service.yaml").Flatten(). FilenameParam(false, false, "../../../examples/guestbook/redis-master-service.yaml").Flatten().
Do().Watch("12") Do().Watch("12")
if err != nil { if err != nil {
@ -908,8 +1074,8 @@ func TestWatch(t *testing.T) {
func TestWatchMultipleError(t *testing.T) { func TestWatchMultipleError(t *testing.T) {
_, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). _, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()).
NamespaceParam("test").DefaultNamespace(). NamespaceParam("test").DefaultNamespace().
FilenameParam(false, "../../../examples/guestbook/redis-master-controller.yaml").Flatten(). FilenameParam(false, false, "../../../examples/guestbook/redis-master-controller.yaml").Flatten().
FilenameParam(false, "../../../examples/guestbook/redis-master-controller.yaml").Flatten(). FilenameParam(false, false, "../../../examples/guestbook/redis-master-controller.yaml").Flatten().
Do().Watch("") Do().Watch("")
if err == nil { if err == nil {