mirror of https://github.com/k3s-io/k3s
commit
2f90f660c1
|
@ -13,6 +13,7 @@ docs/man/man1/kubectl-config-unset.1
|
|||
docs/man/man1/kubectl-config-use-context.1
|
||||
docs/man/man1/kubectl-config-view.1
|
||||
docs/man/man1/kubectl-config.1
|
||||
docs/man/man1/kubectl-convert.1
|
||||
docs/man/man1/kubectl-create.1
|
||||
docs/man/man1/kubectl-delete.1
|
||||
docs/man/man1/kubectl-describe.1
|
||||
|
@ -48,6 +49,7 @@ docs/user-guide/kubectl/kubectl_config_set.md
|
|||
docs/user-guide/kubectl/kubectl_config_unset.md
|
||||
docs/user-guide/kubectl/kubectl_config_use-context.md
|
||||
docs/user-guide/kubectl/kubectl_config_view.md
|
||||
docs/user-guide/kubectl/kubectl_convert.md
|
||||
docs/user-guide/kubectl/kubectl_create.md
|
||||
docs/user-guide/kubectl/kubectl_delete.md
|
||||
docs/user-guide/kubectl/kubectl_describe.md
|
||||
|
|
|
@ -1152,6 +1152,41 @@ _kubectl_explain()
|
|||
must_have_one_noun=()
|
||||
}
|
||||
|
||||
_kubectl_convert()
|
||||
{
|
||||
last_command="kubectl_convert"
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--filename=")
|
||||
flags_with_completion+=("--filename")
|
||||
flags_completion+=("__handle_filename_extension_flag json|stdin|yaml|yml")
|
||||
two_word_flags+=("-f")
|
||||
flags_with_completion+=("-f")
|
||||
flags_completion+=("__handle_filename_extension_flag json|stdin|yaml|yml")
|
||||
flags+=("--local")
|
||||
flags+=("--no-headers")
|
||||
flags+=("--output=")
|
||||
two_word_flags+=("-o")
|
||||
flags+=("--output-version=")
|
||||
flags+=("--schema-cache-dir=")
|
||||
flags+=("--show-all")
|
||||
flags+=("-a")
|
||||
flags+=("--sort-by=")
|
||||
flags+=("--template=")
|
||||
two_word_flags+=("-t")
|
||||
flags+=("--validate")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_flag+=("--filename=")
|
||||
must_have_one_flag+=("-f")
|
||||
must_have_one_noun=()
|
||||
}
|
||||
|
||||
_kubectl()
|
||||
{
|
||||
last_command="kubectl"
|
||||
|
@ -1182,6 +1217,7 @@ _kubectl()
|
|||
commands+=("api-versions")
|
||||
commands+=("version")
|
||||
commands+=("explain")
|
||||
commands+=("convert")
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
|
|
|
@ -11,6 +11,7 @@ kubectl-config-unset.1
|
|||
kubectl-config-use-context.1
|
||||
kubectl-config-view.1
|
||||
kubectl-config.1
|
||||
kubectl-convert.1
|
||||
kubectl-create.1
|
||||
kubectl-delete.1
|
||||
kubectl-describe.1
|
||||
|
|
|
@ -0,0 +1,195 @@
|
|||
.TH "KUBERNETES" "1" " kubernetes User Manuals" "Eric Paris" "Jan 2015" ""
|
||||
|
||||
|
||||
.SH NAME
|
||||
.PP
|
||||
kubectl convert \- Convert config files between different API versions
|
||||
|
||||
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\fBkubectl convert\fP [OPTIONS]
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Convert config files between different API versions. Both YAML
|
||||
and JSON formats are accepted.
|
||||
|
||||
.PP
|
||||
The command takes filename, directory, or URL as input, and convert it into format
|
||||
of version specified by \-\-output\-version flag. If target version is not specified or
|
||||
not supported, convert to latest version.
|
||||
|
||||
.PP
|
||||
The default output will be printed to stdout in YAML format. One can use \-o option
|
||||
to change to output destination.
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.PP
|
||||
\fB\-f\fP, \fB\-\-filename\fP=[]
|
||||
Filename, directory, or URL to file to need to get converted.
|
||||
|
||||
.PP
|
||||
\fB\-\-local\fP=true
|
||||
If true, convert will NOT try to contact api\-server but run locally.
|
||||
|
||||
.PP
|
||||
\fB\-\-no\-headers\fP=false
|
||||
When using the default output, don't print headers.
|
||||
|
||||
.PP
|
||||
\fB\-o\fP, \fB\-\-output\fP=""
|
||||
Output format. One of: json|yaml|wide|name|go\-template=...|go\-template\-file=...|jsonpath=...|jsonpath\-file=... See golang template [
|
||||
\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]] and jsonpath template [
|
||||
\[la]http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md\[ra]].
|
||||
|
||||
.PP
|
||||
\fB\-\-output\-version\fP=""
|
||||
Output the formatted object with the given version (default api\-version).
|
||||
|
||||
.PP
|
||||
\fB\-\-schema\-cache\-dir\fP="\~/.kube/schema"
|
||||
If non\-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
|
||||
|
||||
.PP
|
||||
\fB\-a\fP, \fB\-\-show\-all\fP=false
|
||||
When printing, show all resources (default hide terminated pods.)
|
||||
|
||||
.PP
|
||||
\fB\-\-sort\-by\fP=""
|
||||
If non\-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
|
||||
|
||||
.PP
|
||||
\fB\-t\fP, \fB\-\-template\fP=""
|
||||
Template string or path to template file to use when \-o=go\-template, \-o=go\-template\-file. The template format is golang templates [
|
||||
\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]].
|
||||
|
||||
.PP
|
||||
\fB\-\-validate\fP=true
|
||||
If true, use a schema to validate the input before sending it
|
||||
|
||||
|
||||
.SH OPTIONS INHERITED FROM PARENT COMMANDS
|
||||
.PP
|
||||
\fB\-\-alsologtostderr\fP=false
|
||||
log to standard error as well as files
|
||||
|
||||
.PP
|
||||
\fB\-\-api\-version\fP=""
|
||||
The API version to use when talking to the server
|
||||
|
||||
.PP
|
||||
\fB\-\-certificate\-authority\fP=""
|
||||
Path to a cert. file for the certificate authority.
|
||||
|
||||
.PP
|
||||
\fB\-\-client\-certificate\fP=""
|
||||
Path to a client key file for TLS.
|
||||
|
||||
.PP
|
||||
\fB\-\-client\-key\fP=""
|
||||
Path to a client key file for TLS.
|
||||
|
||||
.PP
|
||||
\fB\-\-cluster\fP=""
|
||||
The name of the kubeconfig cluster to use
|
||||
|
||||
.PP
|
||||
\fB\-\-context\fP=""
|
||||
The name of the kubeconfig context to use
|
||||
|
||||
.PP
|
||||
\fB\-\-insecure\-skip\-tls\-verify\fP=false
|
||||
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
|
||||
|
||||
.PP
|
||||
\fB\-\-kubeconfig\fP=""
|
||||
Path to the kubeconfig file to use for CLI requests.
|
||||
|
||||
.PP
|
||||
\fB\-\-log\-backtrace\-at\fP=:0
|
||||
when logging hits line file:N, emit a stack trace
|
||||
|
||||
.PP
|
||||
\fB\-\-log\-dir\fP=""
|
||||
If non\-empty, write log files in this directory
|
||||
|
||||
.PP
|
||||
\fB\-\-log\-flush\-frequency\fP=5s
|
||||
Maximum number of seconds between log flushes
|
||||
|
||||
.PP
|
||||
\fB\-\-logtostderr\fP=true
|
||||
log to standard error instead of files
|
||||
|
||||
.PP
|
||||
\fB\-\-match\-server\-version\fP=false
|
||||
Require server version to match client version
|
||||
|
||||
.PP
|
||||
\fB\-\-namespace\fP=""
|
||||
If present, the namespace scope for this CLI request.
|
||||
|
||||
.PP
|
||||
\fB\-\-password\fP=""
|
||||
Password for basic authentication to the API server.
|
||||
|
||||
.PP
|
||||
\fB\-s\fP, \fB\-\-server\fP=""
|
||||
The address and port of the Kubernetes API server
|
||||
|
||||
.PP
|
||||
\fB\-\-stderrthreshold\fP=2
|
||||
logs at or above this threshold go to stderr
|
||||
|
||||
.PP
|
||||
\fB\-\-token\fP=""
|
||||
Bearer token for authentication to the API server.
|
||||
|
||||
.PP
|
||||
\fB\-\-user\fP=""
|
||||
The name of the kubeconfig user to use
|
||||
|
||||
.PP
|
||||
\fB\-\-username\fP=""
|
||||
Username for basic authentication to the API server.
|
||||
|
||||
.PP
|
||||
\fB\-\-v\fP=0
|
||||
log level for V logs
|
||||
|
||||
.PP
|
||||
\fB\-\-vmodule\fP=
|
||||
comma\-separated list of pattern=N settings for file\-filtered logging
|
||||
|
||||
|
||||
.SH EXAMPLE
|
||||
.PP
|
||||
.RS
|
||||
|
||||
.nf
|
||||
# Convert 'pod.yaml' to latest version and print to stdout.
|
||||
$ kubectl convert \-f pod.yaml
|
||||
|
||||
# Convert the live state of the resource specified by 'pod.yaml' to the latest version
|
||||
# and print to stdout in json format.
|
||||
$ kubectl convert \-f pod.yaml \-\-local \-o json
|
||||
|
||||
# Convert all files under current directory to latest version and create them all.
|
||||
$ kubectl convert \-f . | kubectl create \-f \-
|
||||
|
||||
|
||||
.fi
|
||||
.RE
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\fBkubectl(1)\fP,
|
||||
|
||||
|
||||
.SH HISTORY
|
||||
.PP
|
||||
January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since!
|
|
@ -116,7 +116,7 @@ Find more information at
|
|||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-replace(1)\fP, \fBkubectl\-patch(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-edit(1)\fP, \fBkubectl\-apply(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-logs(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-scale(1)\fP, \fBkubectl\-attach(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-annotate(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-explain(1)\fP,
|
||||
\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-replace(1)\fP, \fBkubectl\-patch(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-edit(1)\fP, \fBkubectl\-apply(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-logs(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-scale(1)\fP, \fBkubectl\-attach(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-annotate(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-explain(1)\fP, \fBkubectl\-convert(1)\fP,
|
||||
|
||||
|
||||
.SH HISTORY
|
||||
|
|
|
@ -12,6 +12,7 @@ kubectl_config_set.md
|
|||
kubectl_config_unset.md
|
||||
kubectl_config_use-context.md
|
||||
kubectl_config_view.md
|
||||
kubectl_convert.md
|
||||
kubectl_create.md
|
||||
kubectl_delete.md
|
||||
kubectl_describe.md
|
||||
|
|
|
@ -82,6 +82,7 @@ kubectl
|
|||
* [kubectl attach](kubectl_attach.md) - Attach to a running container.
|
||||
* [kubectl cluster-info](kubectl_cluster-info.md) - Display cluster info
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
* [kubectl convert](kubectl_convert.md) - Convert config files between different API versions
|
||||
* [kubectl create](kubectl_create.md) - Create a resource by filename or stdin
|
||||
* [kubectl delete](kubectl_delete.md) - Delete resources by filenames, stdin, resources and names, or by resources and label selector.
|
||||
* [kubectl describe](kubectl_describe.md) - Show details of a specific resource or group of resources
|
||||
|
@ -103,7 +104,7 @@ kubectl
|
|||
* [kubectl stop](kubectl_stop.md) - Deprecated: Gracefully shut down a resource by name or filename.
|
||||
* [kubectl version](kubectl_version.md) - Print the client and server version information.
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 11:13:47.6353025 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl.md?pixel)]()
|
||||
|
|
|
@ -119,7 +119,7 @@ $ kubectl annotate pods foo description-
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.16095949 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293299401 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]()
|
||||
|
|
|
@ -76,7 +76,7 @@ kubectl api-versions
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.164255617 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294634813 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_api-versions.md?pixel)]()
|
||||
|
|
|
@ -98,7 +98,7 @@ $ kubectl attach 123456-7890 -c ruby-container -i -t
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.934629688 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_attach.md?pixel)]()
|
||||
|
|
|
@ -76,7 +76,7 @@ kubectl cluster-info
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163962347 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294524092 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info.md?pixel)]()
|
||||
|
|
|
@ -94,7 +94,7 @@ kubectl config SUBCOMMAND
|
|||
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a kubeconfig file
|
||||
* [kubectl config view](kubectl_config_view.md) - Displays merged kubeconfig settings or a specified kubeconfig file.
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.253683538 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-27 07:12:26.012369724 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config.md?pixel)]()
|
||||
|
|
|
@ -96,7 +96,7 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.161700827 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293649266 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-cluster.md?pixel)]()
|
||||
|
|
|
@ -89,7 +89,7 @@ $ kubectl config set-context gce --user=cluster-admin
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162402642 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293919632 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-context.md?pixel)]()
|
||||
|
|
|
@ -109,7 +109,7 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162045132 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.293801607 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-credentials.md?pixel)]()
|
||||
|
|
|
@ -78,7 +78,7 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.162716308 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294028359 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set.md?pixel)]()
|
||||
|
|
|
@ -77,7 +77,7 @@ kubectl config unset PROPERTY_NAME
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163015642 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294142791 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_unset.md?pixel)]()
|
||||
|
|
|
@ -76,7 +76,7 @@ kubectl config use-context CONTEXT_NAME
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163336177 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294246651 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_use-context.md?pixel)]()
|
||||
|
|
|
@ -103,7 +103,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2
|
|||
|
||||
* [kubectl config](kubectl_config.md) - config modifies kubeconfig files
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.252744701 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-27 07:12:26.010616625 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]()
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
<!-- BEGIN STRIP_FOR_RELEASE -->
|
||||
|
||||
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
<img src="http://kubernetes.io/img/warning.png" alt="WARNING"
|
||||
width="25" height="25">
|
||||
|
||||
<h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2>
|
||||
|
||||
If you are using a released version of Kubernetes, you should
|
||||
refer to the docs that go with that version.
|
||||
|
||||
<strong>
|
||||
The latest 1.0.x release of this document can be found
|
||||
[here](http://releases.k8s.io/release-1.0/docs/user-guide/kubectl/kubectl_convert.md).
|
||||
|
||||
Documentation for other releases can be found at
|
||||
[releases.k8s.io](http://releases.k8s.io).
|
||||
</strong>
|
||||
--
|
||||
|
||||
<!-- END STRIP_FOR_RELEASE -->
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
## kubectl convert
|
||||
|
||||
Convert config files between different API versions
|
||||
|
||||
### Synopsis
|
||||
|
||||
|
||||
Convert config files between different API versions. Both YAML
|
||||
and JSON formats are accepted.
|
||||
|
||||
The command takes filename, directory, or URL as input, and convert it into format
|
||||
of version specified by --output-version flag. If target version is not specified or
|
||||
not supported, convert to latest version.
|
||||
|
||||
The default output will be printed to stdout in YAML format. One can use -o option
|
||||
to change to output destination.
|
||||
|
||||
|
||||
```
|
||||
kubectl convert -f FILENAME
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# Convert 'pod.yaml' to latest version and print to stdout.
|
||||
$ kubectl convert -f pod.yaml
|
||||
|
||||
# Convert the live state of the resource specified by 'pod.yaml' to the latest version
|
||||
# and print to stdout in json format.
|
||||
$ kubectl convert -f pod.yaml --local -o json
|
||||
|
||||
# Convert all files under current directory to latest version and create them all.
|
||||
$ kubectl convert -f . | kubectl create -f -
|
||||
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-f, --filename=[]: Filename, directory, or URL to file to need to get converted.
|
||||
--local[=true]: If true, convert will NOT try to contact api-server but run locally.
|
||||
--no-headers[=false]: When using the default output, don't print headers.
|
||||
-o, --output="": Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md].
|
||||
--output-version="": Output the formatted object with the given version (default api-version).
|
||||
--schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
|
||||
-a, --show-all[=false]: When printing, show all resources (default hide terminated pods.)
|
||||
--sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
|
||||
--template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
|
||||
--validate[=true]: If true, use a schema to validate the input before sending it
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--alsologtostderr[=false]: log to standard error as well as files
|
||||
--api-version="": The API version to use when talking to the server
|
||||
--certificate-authority="": Path to a cert. file for the certificate authority.
|
||||
--client-certificate="": Path to a client key file for TLS.
|
||||
--client-key="": Path to a client key file for TLS.
|
||||
--cluster="": The name of the kubeconfig cluster to use
|
||||
--context="": The name of the kubeconfig context to use
|
||||
--insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
|
||||
--kubeconfig="": Path to the kubeconfig file to use for CLI requests.
|
||||
--log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
|
||||
--log-dir="": If non-empty, write log files in this directory
|
||||
--log-flush-frequency=5s: Maximum number of seconds between log flushes
|
||||
--logtostderr[=true]: log to standard error instead of files
|
||||
--match-server-version[=false]: Require server version to match client version
|
||||
--namespace="": If present, the namespace scope for this CLI request.
|
||||
--password="": Password for basic authentication to the API server.
|
||||
-s, --server="": The address and port of the Kubernetes API server
|
||||
--stderrthreshold=2: logs at or above this threshold go to stderr
|
||||
--token="": Bearer token for authentication to the API server.
|
||||
--user="": The name of the kubeconfig user to use
|
||||
--username="": Username for basic authentication to the API server.
|
||||
--v=0: log level for V logs
|
||||
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_convert.md?pixel)]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
|
@ -97,7 +97,7 @@ $ cat pod.json | kubectl create -f -
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.399116592 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create.md?pixel)]()
|
||||
|
|
|
@ -119,7 +119,7 @@ $ kubectl delete pods --all
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.153952299 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290276028 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_delete.md?pixel)]()
|
||||
|
|
|
@ -119,7 +119,7 @@ $ kubectl describe pods frontend
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.152057668 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.289638749 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_describe.md?pixel)]()
|
||||
|
|
|
@ -114,7 +114,7 @@ kubectl edit (RESOURCE/NAME | -f FILENAME)
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-16 00:43:02.024642139 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290401559 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_edit.md?pixel)]()
|
||||
|
|
|
@ -99,7 +99,7 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.934818621 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_exec.md?pixel)]()
|
||||
|
|
|
@ -125,7 +125,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-14 01:48:52.452547937 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.292344962 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_expose.md?pixel)]()
|
||||
|
|
|
@ -132,7 +132,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.151532564 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.288852192 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_get.md?pixel)]()
|
||||
|
|
|
@ -120,7 +120,7 @@ $ kubectl label pods foo bar-
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.160594172 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.29251561 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_label.md?pixel)]()
|
||||
|
|
|
@ -109,7 +109,7 @@ $ kubectl logs --since=1h nginx
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-16 18:54:52.319210951 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290730658 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_logs.md?pixel)]()
|
||||
|
|
|
@ -79,7 +79,7 @@ kubectl namespace [namespace]
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.154262869 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290510762 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_namespace.md?pixel)]()
|
||||
|
|
|
@ -102,7 +102,7 @@ kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.153568922 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.290134655 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_patch.md?pixel)]()
|
||||
|
|
|
@ -99,7 +99,7 @@ $ kubectl port-forward mypod 0:5000
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.156433376 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.291494553 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_port-forward.md?pixel)]()
|
||||
|
|
|
@ -122,7 +122,7 @@ $ kubectl proxy --api-prefix=/k8s-api
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-30 13:52:13.608206963 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_proxy.md?pixel)]()
|
||||
|
|
|
@ -111,7 +111,7 @@ kubectl replace --force -f ./pod.json
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.399461456 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_replace.md?pixel)]()
|
||||
|
|
|
@ -119,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-17 21:39:48.40113721 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]()
|
||||
|
|
|
@ -135,7 +135,7 @@ $ kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-28 05:58:08.93540785 +0000 UTC
|
||||
###### Auto generated by spf13/cobra on 9-Oct-2015
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_run.md?pixel)]()
|
||||
|
|
|
@ -108,7 +108,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.155304524 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.291112 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_scale.md?pixel)]()
|
||||
|
|
|
@ -110,7 +110,7 @@ $ kubectl stop -f path/to/resources
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.158360787 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.292142116 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_stop.md?pixel)]()
|
||||
|
|
|
@ -82,7 +82,7 @@ kubectl version
|
|||
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.164581808 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-09-22 12:53:42.294832043 +0000 UTC
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_version.md?pixel)]()
|
||||
|
|
|
@ -174,6 +174,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
|
|||
cmds.AddCommand(NewCmdApiVersions(f, out))
|
||||
cmds.AddCommand(NewCmdVersion(f, out))
|
||||
cmds.AddCommand(NewCmdExplain(f, out))
|
||||
cmds.AddCommand(NewCmdConvert(f, out))
|
||||
|
||||
return cmds
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/latest"
|
||||
"k8s.io/kubernetes/pkg/api/registered"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
convert_long = `Convert config files between different API versions. Both YAML
|
||||
and JSON formats are accepted.
|
||||
|
||||
The command takes filename, directory, or URL as input, and convert it into format
|
||||
of version specified by --output-version flag. If target version is not specified or
|
||||
not supported, convert to latest version.
|
||||
|
||||
The default output will be printed to stdout in YAML format. One can use -o option
|
||||
to change to output destination.
|
||||
`
|
||||
convert_example = `# Convert 'pod.yaml' to latest version and print to stdout.
|
||||
$ kubectl convert -f pod.yaml
|
||||
|
||||
# Convert the live state of the resource specified by 'pod.yaml' to the latest version
|
||||
# and print to stdout in json format.
|
||||
$ kubectl convert -f pod.yaml --local -o json
|
||||
|
||||
# Convert all files under current directory to latest version and create them all.
|
||||
$ kubectl convert -f . | kubectl create -f -
|
||||
`
|
||||
)
|
||||
|
||||
// NewCmdConvert creates a command object for the generic "convert" action, which
|
||||
// translates the config file into a given version.
|
||||
func NewCmdConvert(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
options := &ConvertOptions{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "convert -f FILENAME",
|
||||
Short: "Convert config files between different API versions",
|
||||
Long: convert_long,
|
||||
Example: convert_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := options.Complete(f, out, cmd, args)
|
||||
cmdutil.CheckErr(err)
|
||||
err = options.RunConvert()
|
||||
cmdutil.CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
usage := "Filename, directory, or URL to file to need to get converted."
|
||||
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
|
||||
cmd.MarkFlagRequired("filename")
|
||||
cmdutil.AddValidateFlags(cmd)
|
||||
cmdutil.AddPrinterFlags(cmd)
|
||||
cmd.Flags().BoolVar(&options.local, "local", true, "If true, convert will NOT try to contact api-server but run locally.")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// ConvertOptions have the data required to perform the convert operation
|
||||
type ConvertOptions struct {
|
||||
builder *resource.Builder
|
||||
filenames []string
|
||||
local bool
|
||||
|
||||
out io.Writer
|
||||
printer kubectl.ResourcePrinter
|
||||
|
||||
outputVersion string
|
||||
}
|
||||
|
||||
// Complete collects information required to run Convert command from command line.
|
||||
func (o *ConvertOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {
|
||||
o.outputVersion = cmdutil.OutputVersion(cmd, latest.GroupOrDie("").Version)
|
||||
if !registered.IsRegisteredAPIVersion(o.outputVersion) {
|
||||
cmdutil.UsageError(cmd, "'%s' is not a registered version.", o.outputVersion)
|
||||
}
|
||||
|
||||
// build the builder
|
||||
mapper, typer := f.Object()
|
||||
if o.local {
|
||||
fmt.Fprintln(out, "running in local mode...")
|
||||
o.builder = resource.NewBuilder(mapper, typer, f.NilClientMapperForCommand())
|
||||
} else {
|
||||
o.builder = resource.NewBuilder(mapper, typer, f.ClientMapperForCommand())
|
||||
schema, err := f.Validator(cmdutil.GetFlagBool(cmd, "validate"), cmdutil.GetFlagString(cmd, "schema-cache-dir"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.builder = o.builder.Schema(schema)
|
||||
}
|
||||
cmdNamespace, _, err := f.DefaultNamespace()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.builder = o.builder.NamespaceParam(cmdNamespace).
|
||||
ContinueOnError().
|
||||
FilenameParam(false, o.filenames...).
|
||||
Flatten()
|
||||
|
||||
// build the printer
|
||||
o.out = out
|
||||
outputFormat := cmdutil.GetFlagString(cmd, "output")
|
||||
templateFile := cmdutil.GetFlagString(cmd, "template")
|
||||
if len(outputFormat) == 0 {
|
||||
if len(templateFile) == 0 {
|
||||
outputFormat = "yaml"
|
||||
} else {
|
||||
outputFormat = "template"
|
||||
}
|
||||
}
|
||||
o.printer, _, err = kubectl.GetPrinter(outputFormat, templateFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunConvert implements the generic Convert command
|
||||
func (o *ConvertOptions) RunConvert() error {
|
||||
infos, err := o.builder.Do().Infos()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
objects, err := resource.AsVersionedObject(infos, false, o.outputVersion)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return o.printer.PrintObj(objects, o.out)
|
||||
}
|
|
@ -532,3 +532,11 @@ func (f *Factory) ClientMapperForCommand() resource.ClientMapper {
|
|||
return f.RESTClient(mapping)
|
||||
})
|
||||
}
|
||||
|
||||
// NilClientMapperForCommand returns a ClientMapper which always returns nil.
|
||||
// When command is running locally and client isn't needed, this mapper can be parsed to NewBuilder.
|
||||
func (f *Factory) NilClientMapperForCommand() resource.ClientMapper {
|
||||
return resource.ClientMapperFunc(func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
|
||||
return nil, nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to connect to a server to handle %q: %v", mapping.Resource, err)
|
||||
}
|
||||
|
||||
name, _ := mapping.MetadataAccessor.Name(obj)
|
||||
namespace, _ := mapping.MetadataAccessor.Namespace(obj)
|
||||
resourceVersion, _ := mapping.MetadataAccessor.ResourceVersion(obj)
|
||||
|
|
Loading…
Reference in New Issue