Extract a bunch more strings from kubectl

pull/6/head
Brendan Burns 2017-03-14 20:49:10 -07:00
parent 27cf62ac29
commit 79f51923d3
60 changed files with 14984 additions and 1669 deletions

View File

@ -59,8 +59,16 @@ fi
if [[ "${generate_pot}" == "true" ]]; then
echo "Extracting strings to POT"
go-xgettext -k=i18n.T ${KUBECTL_FILES} > tmp.pot
msgcat -s tmp.pot > translations/kubectl/template.pot
rm tmp.pot
perl -pi -e 's/CHARSET/UTF-8/' tmp.pot
perl -pi -e 's/\\\(/\\\\\(/g' tmp.pot
perl -pi -e 's/\\\)/\\\\\)/g' tmp.pot
if msgcat -s tmp.pot > /tmp/template.pot; then
mv /tmp/template.pot translations/kubectl/template.pot
rm tmp.pot
else
echo "Failed to update template.pot"
exit 1
fi
fi
if [[ "${generate_mo}" == "true" ]]; then

File diff suppressed because one or more lines are too long

View File

@ -207,6 +207,7 @@ go_test(
"//pkg/kubectl/resource:go_default_library",
"//pkg/printers:go_default_library",
"//pkg/printers/internalversion:go_default_library",
"//pkg/util/i18n:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/util/term:go_default_library",
"//vendor:github.com/spf13/cobra",

View File

@ -75,7 +75,7 @@ var (
` + valid_resources)
annotate_example = templates.Examples(`
annotate_example = templates.Examples(i18n.T(`
# Update pod 'foo' with the annotation 'description' and the value 'my frontend'.
# If the same annotation is set multiple times, only the last value will be applied
kubectl annotate pods foo description='my frontend'
@ -94,7 +94,7 @@ var (
# Update pod 'foo' by removing an annotation named 'description' if it exists.
# Does not require the --overwrite flag.
kubectl annotate pods foo description-`)
kubectl annotate pods foo description-`))
)
func NewCmdAnnotate(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -27,12 +27,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)
var (
apiversions_example = templates.Examples(`
apiversions_example = templates.Examples(i18n.T(`
# Print the supported API versions
kubectl api-versions`)
kubectl api-versions`))
)
func NewCmdApiVersions(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -72,16 +72,16 @@ const (
)
var (
apply_long = templates.LongDesc(`
apply_long = templates.LongDesc(i18n.T(`
Apply a configuration to a resource by filename or stdin.
This resource will be created if it doesn't exist yet.
To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.
JSON and YAML formats are accepted.
Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.`)
Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.`))
apply_example = templates.Examples(`
apply_example = templates.Examples(i18n.T(`
# Apply the configuration in pod.json to a pod.
kubectl apply -f ./pod.json
@ -93,7 +93,7 @@ var (
kubectl apply --prune -f manifest.yaml -l app=nginx
# Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap`)
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap`))
)
func NewCmdApply(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {

View File

@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/i18n"
)
type SetLastAppliedOptions struct {
@ -58,12 +59,12 @@ type SetLastAppliedOptions struct {
}
var (
applySetLastAppliedLong = templates.LongDesc(`
applySetLastAppliedLong = templates.LongDesc(i18n.T(`
Set the latest last-applied-configuration annotations by setting it to match the contents of a file.
This results in the last-applied-configuration being updated as though 'kubectl apply -f <file>' was run,
without updating any other parts of the object.`)
without updating any other parts of the object.`))
applySetLastAppliedExample = templates.Examples(`
applySetLastAppliedExample = templates.Examples(i18n.T(`
# Set the last-applied-configuration of a resource to match the contents of a file.
kubectl apply set-last-applied -f deploy.yaml
@ -72,14 +73,14 @@ var (
# Set the last-applied-configuration of a resource to match the contents of a file, will create the annotation if it does not already exist.
kubectl apply set-last-applied -f deploy.yaml --create-annotation=true
`)
`))
)
func NewCmdApplySetLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
options := &SetLastAppliedOptions{Out: out, ErrOut: err}
cmd := &cobra.Command{
Use: "set-last-applied -f FILENAME",
Short: "Set the last-applied-configuration annotation on a live object to match the contents of a file.",
Short: i18n.T("Set the last-applied-configuration annotation on a live object to match the contents of a file."),
Long: applySetLastAppliedLong,
Example: applySetLastAppliedExample,
Run: func(cmd *cobra.Command, args []string) {

View File

@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/i18n"
)
type ViewLastAppliedOptions struct {
@ -42,25 +43,25 @@ type ViewLastAppliedOptions struct {
}
var (
applyViewLastAppliedLong = templates.LongDesc(`
applyViewLastAppliedLong = templates.LongDesc(i18n.T(`
View the latest last-applied-configuration annotations by type/name or file.
The default output will be printed to stdout in YAML format. One can use -o option
to change output format.`)
to change output format.`))
applyViewLastAppliedExample = templates.Examples(`
applyViewLastAppliedExample = templates.Examples(i18n.T(`
# View the last-applied-configuration annotations by type/name in YAML.
kubectl apply view-last-applied deployment/nginx
# View the last-applied-configuration annotations by file in JSON
kubectl apply view-last-applied -f deploy.yaml -o json`)
kubectl apply view-last-applied -f deploy.yaml -o json`))
)
func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
options := &ViewLastAppliedOptions{Out: out, ErrOut: err}
cmd := &cobra.Command{
Use: "view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)",
Short: "View latest last-applied-configuration annotations of a resource/object",
Short: i18n.T("View latest last-applied-configuration annotations of a resource/object"),
Long: applyViewLastAppliedLong,
Example: applyViewLastAppliedExample,
Run: func(cmd *cobra.Command, args []string) {

View File

@ -40,7 +40,7 @@ import (
)
var (
attach_example = templates.Examples(`
attach_example = templates.Examples(i18n.T(`
# Get output from running pod 123456-7890, using the first container by default
kubectl attach 123456-7890
@ -53,7 +53,7 @@ var (
# Get output from the first pod of a ReplicaSet named nginx
kubectl attach rs/nginx
`)
`))
)
const (

View File

@ -31,18 +31,18 @@ import (
)
var (
autoscaleLong = templates.LongDesc(`
autoscaleLong = templates.LongDesc(i18n.T(`
Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.
Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference.
An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.`)
An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.`))
autoscaleExample = templates.Examples(`
autoscaleExample = templates.Examples(i18n.T(`
# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10
# Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80`)
kubectl autoscale rc foo --max=5 --cpu-percent=80`))
)
func NewCmdAutoscale(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -34,13 +34,13 @@ import (
)
var (
longDescr = templates.LongDesc(`
longDescr = templates.LongDesc(i18n.T(`
Display addresses of the master and services with label kubernetes.io/cluster-service=true
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`)
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`))
clusterinfo_example = templates.Examples(`
clusterinfo_example = templates.Examples(i18n.T(`
# Print the address of the master and cluster services
kubectl cluster-info`)
kubectl cluster-info`))
)
func NewCmdClusterInfo(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -51,16 +51,16 @@ func NewCmdClusterInfoDump(f cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
}
var (
dumpLong = templates.LongDesc(`
dumpLong = templates.LongDesc(i18n.T(`
Dumps cluster info out suitable for debugging and diagnosing cluster problems. By default, dumps everything to
stdout. You can optionally specify a directory with --output-directory. If you specify a directory, kubernetes will
build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can
switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.
The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories
based on namespace and pod name.`)
based on namespace and pod name.`))
dumpExample = templates.Examples(`
dumpExample = templates.Examples(i18n.T(`
# Dump current cluster state to stdout
kubectl cluster-info dump
@ -71,7 +71,7 @@ var (
kubectl cluster-info dump --all-namespaces
# Dump a set of namespaces to /path/to/cluster-state
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state`)
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state`))
)
func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename string) io.Writer {

View File

@ -44,7 +44,7 @@ const defaultBoilerPlate = `
`
var (
completion_long = templates.LongDesc(`
completion_long = templates.LongDesc(i18n.T(`
Output shell completion code for the specified shell (bash or zsh).
The shell code must be evalutated to provide interactive
completion of kubectl commands. This can be done by sourcing it from
@ -60,12 +60,15 @@ var (
$ source $(brew --prefix)/etc/bash_completion
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`)
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`))
completion_example = templates.Examples(`
completion_example = templates.Examples(i18n.T(`
# Install bash completion on a Mac using homebrew
brew install bash-completion
printf "\n# Bash completion support\nsource $(brew --prefix)/etc/bash_completion\n" >> $HOME/.bash_profile
printf "
# Bash completion support
source $(brew --prefix)/etc/bash_completion
" >> $HOME/.bash_profile
source $HOME/.bash_profile
# Load the kubectl completion code for bash into the current shell
@ -73,11 +76,14 @@ var (
# Write bash completion code to a file and source if from .bash_profile
kubectl completion bash > ~/.kube/completion.bash.inc
printf "\n# Kubectl shell completion\nsource '$HOME/.kube/completion.bash.inc'\n" >> $HOME/.bash_profile
printf "
# Kubectl shell completion
source '$HOME/.kube/completion.bash.inc'
" >> $HOME/.bash_profile
source $HOME/.bash_profile
# Load the kubectl completion code for zsh[1] into the current shell
source <(kubectl completion zsh)`)
source <(kubectl completion zsh)`))
)
var (

View File

@ -35,7 +35,7 @@ import (
)
var (
convert_long = templates.LongDesc(`
convert_long = templates.LongDesc(i18n.T(`
Convert config files between different API versions. Both YAML
and JSON formats are accepted.
@ -44,9 +44,9 @@ var (
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.`)
to change to output destination.`))
convert_example = templates.Examples(`
convert_example = templates.Examples(i18n.T(`
# Convert 'pod.yaml' to latest version and print to stdout.
kubectl convert -f pod.yaml
@ -55,7 +55,7 @@ var (
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 -`)
kubectl convert -f . | kubectl create -f -`))
)
// NewCmdConvert creates a command object for the generic "convert" action, which
@ -82,7 +82,7 @@ func NewCmdConvert(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmdutil.AddValidateFlags(cmd)
cmdutil.AddNonDeprecatedPrinterFlags(cmd)
cmd.Flags().BoolVar(&options.local, "local", true, "If true, convert will NOT try to contact api-server but run locally.")
cmd.Flags().String("output-version", "", "Output the formatted object with the given group version (for ex: 'extensions/v1beta1').")
cmd.Flags().String("output-version", "", i18n.T("Output the formatted object with the given group version (for ex: 'extensions/v1beta1').)"))
cmdutil.AddInclude3rdPartyFlags(cmd)
return cmd
}

View File

@ -34,7 +34,7 @@ import (
)
var (
cp_example = templates.Examples(`
cp_example = templates.Examples(i18n.T(`
# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image. If 'tar' is not present, 'kubectl cp' will fail.
@ -49,7 +49,7 @@ var (
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
# Copy /tmp/foo from a remote pod to /tmp/bar locally
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar`)
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar`))
cpUsageStr = dedent.Dedent(`
expected 'cp <file-spec-src> <file-spec-dest> [-c container]'.

View File

@ -39,12 +39,12 @@ type CreateOptions struct {
}
var (
create_long = templates.LongDesc(`
create_long = templates.LongDesc(i18n.T(`
Create a resource by filename or stdin.
JSON and YAML formats are accepted.`)
JSON and YAML formats are accepted.`))
create_example = templates.Examples(`
create_example = templates.Examples(i18n.T(`
# Create a pod using the data in pod.json.
kubectl create -f ./pod.json
@ -52,7 +52,7 @@ var (
cat pod.json | kubectl create -f -
# Edit the data in docker-registry.yaml in JSON using the v1 API format then create the resource using the edited data.
kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json`)
kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json`))
)
func NewCmdCreate(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {

View File

@ -24,18 +24,19 @@ import (
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)
var (
clusterRoleLong = templates.LongDesc(`
Create a ClusterRole.`)
clusterRoleLong = templates.LongDesc(i18n.T(`
Create a ClusterRole.`))
clusterRoleExample = templates.Examples(`
clusterRoleExample = templates.Examples(i18n.T(`
# Create a ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" on pods
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods
# Create a ClusterRole named "pod-reader" with ResourceName specified
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods --resource-name=readablepod`)
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods --resource-name=readablepod`))
)
type CreateClusterRoleOptions struct {

View File

@ -29,12 +29,12 @@ import (
)
var (
clusterRoleBindingLong = templates.LongDesc(`
Create a ClusterRoleBinding for a particular ClusterRole.`)
clusterRoleBindingLong = templates.LongDesc(i18n.T(`
Create a ClusterRoleBinding for a particular ClusterRole.`))
clusterRoleBindingExample = templates.Examples(`
clusterRoleBindingExample = templates.Examples(i18n.T(`
# Create a ClusterRoleBinding for user1, user2, and group1 using the cluster-admin ClusterRole
kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1`)
kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1`))
)
// ClusterRoleBinding is a command to ease creating ClusterRoleBindings.

View File

@ -29,7 +29,7 @@ import (
)
var (
configMapLong = templates.LongDesc(`
configMapLong = templates.LongDesc(i18n.T(`
Create a configmap based on a file, directory, or specified literal value.
A single configmap may package one or more key/value pairs.
@ -39,9 +39,9 @@ var (
When creating a configmap based on a directory, each file whose basename is a valid key in the directory will be
packaged into the configmap. Any directory entries except regular files are ignored (e.g. subdirectories,
symlinks, devices, pipes, etc).`)
symlinks, devices, pipes, etc).`))
configMapExample = templates.Examples(`
configMapExample = templates.Examples(i18n.T(`
# Create a new configmap named my-config based on folder bar
kubectl create configmap my-config --from-file=path/to/bar
@ -55,7 +55,7 @@ var (
kubectl create configmap my-config --from-file=path/to/bar
# Create a new configmap named my-config from an env file
kubectl create configmap my-config --from-env-file=path/to/bar.env`)
kubectl create configmap my-config --from-env-file=path/to/bar.env`))
)
// ConfigMap is a command to ease creating ConfigMaps.

View File

@ -30,12 +30,12 @@ import (
)
var (
deploymentLong = templates.LongDesc(`
Create a deployment with the specified name.`)
deploymentLong = templates.LongDesc(i18n.T(`
Create a deployment with the specified name.`))
deploymentExample = templates.Examples(`
deploymentExample = templates.Examples(i18n.T(`
# Create a new deployment named my-dep that runs the busybox image.
kubectl create deployment my-dep --image=busybox`)
kubectl create deployment my-dep --image=busybox`))
)
// NewCmdCreateDeployment is a macro command to create a new deployment

View File

@ -29,12 +29,12 @@ import (
)
var (
namespaceLong = templates.LongDesc(`
Create a namespace with the specified name.`)
namespaceLong = templates.LongDesc(i18n.T(`
Create a namespace with the specified name.`))
namespaceExample = templates.Examples(`
namespaceExample = templates.Examples(i18n.T(`
# Create a new namespace named my-namespace
kubectl create namespace my-namespace`)
kubectl create namespace my-namespace`))
)
// NewCmdCreateNamespace is a macro command to create a new namespace

View File

@ -29,17 +29,17 @@ import (
)
var (
pdbLong = templates.LongDesc(`
Create a pod disruption budget with the specified name, selector, and desired minimum available pods`)
pdbLong = templates.LongDesc(i18n.T(`
Create a pod disruption budget with the specified name, selector, and desired minimum available pods`))
pdbExample = templates.Examples(`
pdbExample = templates.Examples(i18n.T(`
# Create a pod disruption budget named my-pdb that will select all pods with the app=rails label
# and require at least one of them being available at any point in time.
kubectl create poddisruptionbudget my-pdb --selector=app=rails --min-available=1
# Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label
# and require at least half of the pods selected to be available at any point in time.
kubectl create pdb my-pdb --selector=app=nginx --min-available=50%`)
kubectl create pdb my-pdb --selector=app=nginx --min-available=50%`))
)
// NewCmdCreatePodDisruptionBudget is a macro command to create a new pod disruption budget.

View File

@ -29,15 +29,15 @@ import (
)
var (
quotaLong = templates.LongDesc(`
Create a resourcequota with the specified name, hard limits and optional scopes`)
quotaLong = templates.LongDesc(i18n.T(`
Create a resourcequota with the specified name, hard limits and optional scopes`))
quotaExample = templates.Examples(`
quotaExample = templates.Examples(i18n.T(`
# Create a new resourcequota named my-quota
kubectl create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10
# Create a new resourcequota named best-effort
kubectl create quota best-effort --hard=pods=100 --scopes=BestEffort`)
kubectl create quota best-effort --hard=pods=100 --scopes=BestEffort`))
)
// NewCmdCreateQuota is a macro command to create a new quota

View File

@ -31,18 +31,19 @@ import (
internalversionrbac "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)
var (
roleLong = templates.LongDesc(`
Create a role with single rule.`)
roleLong = templates.LongDesc(i18n.T(`
Create a role with single rule.`))
roleExample = templates.Examples(`
roleExample = templates.Examples(i18n.T(`
# Create a Role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods
kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods
# Create a Role named "pod-reader" with ResourceName specified
kubectl create role pod-reader --verb=get --verg=list --verb=watch --resource=pods --resource-name=readablepod`)
kubectl create role pod-reader --verb=get --verg=list --verb=watch --resource=pods --resource-name=readablepod`))
// Valid resource verb list for validation.
validResourceVerbs = []string{"*", "get", "delete", "list", "create", "update", "patch", "watch", "proxy", "redirect", "deletecollection", "use"}

View File

@ -29,12 +29,12 @@ import (
)
var (
roleBindingLong = templates.LongDesc(`
Create a RoleBinding for a particular Role or ClusterRole.`)
roleBindingLong = templates.LongDesc(i18n.T(`
Create a RoleBinding for a particular Role or ClusterRole.`))
roleBindingExample = templates.Examples(`
roleBindingExample = templates.Examples(i18n.T(`
# Create a RoleBinding for user1, user2, and group1 using the admin ClusterRole
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1`)
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1`))
)
// RoleBinding is a command to ease creating RoleBindings.

View File

@ -44,7 +44,7 @@ func NewCmdCreateSecret(f cmdutil.Factory, cmdOut, errOut io.Writer) *cobra.Comm
}
var (
secretLong = templates.LongDesc(`
secretLong = templates.LongDesc(i18n.T(`
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
@ -54,9 +54,9 @@ var (
When creating a secret based on a directory, each file whose basename is a valid key in the directory will be
packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories,
symlinks, devices, pipes, etc).`)
symlinks, devices, pipes, etc).`))
secretExample = templates.Examples(`
secretExample = templates.Examples(i18n.T(`
# Create a new secret named my-secret with keys for each file in folder bar
kubectl create secret generic my-secret --from-file=path/to/bar
@ -67,7 +67,7 @@ var (
kubectl create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret
# Create a new secret named my-secret from an env file
kubectl create secret generic my-secret --from-env-file=path/to/bar.env`)
kubectl create secret generic my-secret --from-env-file=path/to/bar.env`))
)
// NewCmdCreateSecretGeneric is a command to create generic secrets from files, directories, or literal values
@ -121,7 +121,7 @@ func CreateSecretGeneric(f cmdutil.Factory, cmdOut io.Writer, cmd *cobra.Command
}
var (
secretForDockerRegistryLong = templates.LongDesc(`
secretForDockerRegistryLong = templates.LongDesc(i18n.T(`
Create a new secret for use with Docker registries.
Dockercfg secrets are used to authenticate against Docker registries.
@ -135,11 +135,11 @@ var (
When creating applications, you may have a Docker registry that requires authentication. In order for the
nodes to pull images on your behalf, they have to have the credentials. You can provide this information
by creating a dockercfg secret and attaching it to your service account.`)
by creating a dockercfg secret and attaching it to your service account.`))
secretForDockerRegistryExample = templates.Examples(`
secretForDockerRegistryExample = templates.Examples(i18n.T(`
# If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using:
kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL`)
kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL`))
)
// NewCmdCreateSecretDockerRegistry is a macro command for creating secrets to work with Docker registries
@ -202,14 +202,14 @@ func CreateSecretDockerRegistry(f cmdutil.Factory, cmdOut io.Writer, cmd *cobra.
}
var (
secretForTLSLong = templates.LongDesc(`
secretForTLSLong = templates.LongDesc(i18n.T(`
Create a TLS secret from the given public/private key pair.
The public/private key pair must exist before hand. The public key certificate must be .PEM encoded and match the given private key.`)
The public/private key pair must exist before hand. The public key certificate must be .PEM encoded and match the given private key.`))
secretForTLSExample = templates.Examples(`
secretForTLSExample = templates.Examples(i18n.T(`
# Create a new TLS secret named tls-secret with the given key pair:
kubectl create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key`)
kubectl create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key`))
)
// NewCmdCreateSecretTLS is a macro command for creating secrets to work with Docker registries

View File

@ -47,15 +47,15 @@ func NewCmdCreateService(f cmdutil.Factory, cmdOut, errOut io.Writer) *cobra.Com
}
var (
serviceClusterIPLong = templates.LongDesc(`
Create a clusterIP service with the specified name.`)
serviceClusterIPLong = templates.LongDesc(i18n.T(`
Create a clusterIP service with the specified name.`))
serviceClusterIPExample = templates.Examples(`
serviceClusterIPExample = templates.Examples(i18n.T(`
# Create a new clusterIP service named my-cs
kubectl create service clusterip my-cs --tcp=5678:8080
# Create a new clusterIP service named my-cs (in headless mode)
kubectl create service clusterip my-cs --clusterip="None"`)
kubectl create service clusterip my-cs --clusterip="None"`))
)
func addPortFlags(cmd *cobra.Command) {
@ -110,12 +110,12 @@ func CreateServiceClusterIP(f cmdutil.Factory, cmdOut io.Writer, cmd *cobra.Comm
}
var (
serviceNodePortLong = templates.LongDesc(`
Create a nodeport service with the specified name.`)
serviceNodePortLong = templates.LongDesc(i18n.T(`
Create a nodeport service with the specified name.`))
serviceNodePortExample = templates.Examples(`
serviceNodePortExample = templates.Examples(i18n.T(`
# Create a new nodeport service named my-ns
kubectl create service nodeport my-ns --tcp=5678:8080`)
kubectl create service nodeport my-ns --tcp=5678:8080`))
)
// NewCmdCreateServiceNodePort is a macro command for creating a NodePort service
@ -167,12 +167,12 @@ func CreateServiceNodePort(f cmdutil.Factory, cmdOut io.Writer, cmd *cobra.Comma
}
var (
serviceLoadBalancerLong = templates.LongDesc(`
Create a LoadBalancer service with the specified name.`)
serviceLoadBalancerLong = templates.LongDesc(i18n.T(`
Create a LoadBalancer service with the specified name.`))
serviceLoadBalancerExample = templates.Examples(`
serviceLoadBalancerExample = templates.Examples(i18n.T(`
# Create a new LoadBalancer service named my-lbs
kubectl create service loadbalancer my-lbs --tcp=5678:8080`)
kubectl create service loadbalancer my-lbs --tcp=5678:8080`))
)
// NewCmdCreateServiceLoadBalancer is a macro command for creating a LoadBalancer service
@ -222,16 +222,16 @@ func CreateServiceLoadBalancer(f cmdutil.Factory, cmdOut io.Writer, cmd *cobra.C
}
var (
serviceExternalNameLong = templates.LongDesc(`
serviceExternalNameLong = templates.LongDesc(i18n.T(`
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of
only pods, which will allow application authors to reference services
that exist off platform, on other clusters, or locally.`)
that exist off platform, on other clusters, or locally.`))
serviceExternalNameExample = templates.Examples(`
serviceExternalNameExample = templates.Examples(i18n.T(`
# Create a new ExternalName service named my-ns
kubectl create service externalname my-ns --external-name bar.com`)
kubectl create service externalname my-ns --external-name bar.com`))
)
// NewCmdCreateServiceExternalName is a macro command for creating a ExternalName service

View File

@ -29,12 +29,12 @@ import (
)
var (
serviceAccountLong = templates.LongDesc(`
Create a service account with the specified name.`)
serviceAccountLong = templates.LongDesc(i18n.T(`
Create a service account with the specified name.`))
serviceAccountExample = templates.Examples(`
serviceAccountExample = templates.Examples(i18n.T(`
# Create a new service account named my-service-account
kubectl create serviceaccount my-service-account`)
kubectl create serviceaccount my-service-account`))
)
// NewCmdCreateServiceAccount is a macro command to create a new service account

View File

@ -37,7 +37,7 @@ import (
)
var (
delete_long = templates.LongDesc(`
delete_long = templates.LongDesc(i18n.T(`
Delete resources by filenames, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of the arguments may be specified: filenames,
@ -63,9 +63,9 @@ var (
Note that the delete command does NOT do resource version checks, so if someone
submits an update to a resource right when you submit a delete, their update
will be lost along with the rest of the resource.`)
will be lost along with the rest of the resource.`))
delete_example = templates.Examples(`
delete_example = templates.Examples(i18n.T(`
# Delete a pod using the type and name specified in pod.json.
kubectl delete -f ./pod.json
@ -85,7 +85,7 @@ var (
kubectl delete pod foo --grace-period=0 --force
# Delete all pods
kubectl delete pods --all`)
kubectl delete pods --all`))
)
type DeleteOptions struct {

View File

@ -51,7 +51,7 @@ var (
` + valid_resources)
describe_example = templates.Examples(`
describe_example = templates.Examples(i18n.T(`
# Describe a node
kubectl describe nodes kubernetes-node-emt8.c.myproject.internal
@ -69,7 +69,7 @@ var (
# Describe all pods managed by the 'frontend' replication controller (rc-created pods
# get the name of the rc as a prefix in the pod the name).
kubectl describe pods frontend`)
kubectl describe pods frontend`))
)
func NewCmdDescribe(f cmdutil.Factory, out, cmdErr io.Writer) *cobra.Command {

View File

@ -87,12 +87,12 @@ const (
)
var (
cordon_long = templates.LongDesc(`
Mark node as unschedulable.`)
cordon_long = templates.LongDesc(i18n.T(`
Mark node as unschedulable.`))
cordon_example = templates.Examples(`
cordon_example = templates.Examples(i18n.T(`
# Mark node "foo" as unschedulable.
kubectl cordon foo`)
kubectl cordon foo`))
)
func NewCmdCordon(f cmdutil.Factory, out io.Writer) *cobra.Command {
@ -112,12 +112,12 @@ func NewCmdCordon(f cmdutil.Factory, out io.Writer) *cobra.Command {
}
var (
uncordon_long = templates.LongDesc(`
Mark node as schedulable.`)
uncordon_long = templates.LongDesc(i18n.T(`
Mark node as schedulable.`))
uncordon_example = templates.Examples(`
uncordon_example = templates.Examples(i18n.T(`
# Mark node "foo" as schedulable.
$ kubectl uncordon foo`)
$ kubectl uncordon foo`))
)
func NewCmdUncordon(f cmdutil.Factory, out io.Writer) *cobra.Command {
@ -137,7 +137,7 @@ func NewCmdUncordon(f cmdutil.Factory, out io.Writer) *cobra.Command {
}
var (
drain_long = templates.LongDesc(`
drain_long = templates.LongDesc(i18n.T(`
Drain node in preparation for maintenance.
The given node will be marked unschedulable to prevent new pods from arriving.
@ -160,14 +160,14 @@ var (
When you are ready to put the node back into service, use kubectl uncordon, which
will make the node schedulable again.
![Workflow](http://kubernetes.io/images/docs/kubectl_drain.svg)`)
![Workflow](http://kubernetes.io/images/docs/kubectl_drain.svg)`))
drain_example = templates.Examples(`
drain_example = templates.Examples(i18n.T(`
# Drain node "foo", even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet on it.
$ kubectl drain foo --force
# As above, but abort if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 minutes.
$ kubectl drain foo --grace-period=900`)
$ kubectl drain foo --grace-period=900`))
)
func NewCmdDrain(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {

View File

@ -53,7 +53,7 @@ import (
)
var (
editLong = templates.LongDesc(`
editLong = templates.LongDesc(i18n.T(`
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the
@ -75,9 +75,9 @@ var (
that contains your unapplied changes. The most common error when updating a resource
is another editor changing the resource on the server. When this occurs, you will have
to apply your changes to the newer version of the resource, or update your temporary
saved copy to include the latest resource version.`)
saved copy to include the latest resource version.`))
editExample = templates.Examples(`
editExample = templates.Examples(i18n.T(`
# Edit the service named 'docker-registry':
kubectl edit svc/docker-registry
@ -88,7 +88,7 @@ var (
kubectl edit job.v1.batch/myjob -o json
# Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation:
kubectl edit deployment/mydeployment -o yaml --save-config`)
kubectl edit deployment/mydeployment -o yaml --save-config`))
)
func NewCmdEdit(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {

View File

@ -38,7 +38,7 @@ import (
)
var (
exec_example = templates.Examples(`
exec_example = templates.Examples(i18n.T(`
# Get output from running 'date' from pod 123456-7890, using the first container by default
kubectl exec 123456-7890 date
@ -47,7 +47,7 @@ var (
# Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890
# and sends stdout/stderr from 'bash' back to the client
kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il`)
kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il`))
)
const (

View File

@ -36,12 +36,12 @@ var (
` + valid_resources)
explainExamples = templates.Examples(`
explainExamples = templates.Examples(i18n.T(`
# Get the documentation of the resource and its fields
kubectl explain pods
# Get the documentation of a specific field of a resource
kubectl explain pods.spec.containers`)
kubectl explain pods.spec.containers`))
)
// NewCmdExplain returns a cobra command for swagger docs

View File

@ -50,7 +50,7 @@ var (
` + expose_resources)
expose_example = templates.Examples(`
expose_example = templates.Examples(i18n.T(`
# Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
kubectl expose rc nginx --port=80 --target-port=8000
@ -70,7 +70,7 @@ var (
kubectl expose rs nginx --port=80 --target-port=8000
# Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.
kubectl expose deployment nginx --port=80 --target-port=8000`)
kubectl expose deployment nginx --port=80 --target-port=8000`))
)
func NewCmdExposeService(f cmdutil.Factory, out io.Writer) *cobra.Command {
@ -101,7 +101,7 @@ func NewCmdExposeService(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().String("port", "", i18n.T("The port that the service should serve on. Copied from the resource being exposed, if unspecified"))
cmd.Flags().String("type", "", i18n.T("Type for this service: ClusterIP, NodePort, or LoadBalancer. Default is 'ClusterIP'."))
cmd.Flags().String("load-balancer-ip", "", i18n.T("IP to assign to the Load Balancer. If empty, an ephemeral IP will be created and used (cloud-provider specific)."))
cmd.Flags().String("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.")
cmd.Flags().String("selector", "", i18n.T("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.)"))
cmd.Flags().StringP("labels", "l", "", "Labels to apply to the service created by this call.")
cmd.Flags().String("container-port", "", i18n.T("Synonym for --target-port"))
cmd.Flags().MarkDeprecated("container-port", "--container-port will be removed in the future, please use --target-port instead")

View File

@ -61,7 +61,7 @@ var (
By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resources.`)
get_example = templates.Examples(`
get_example = templates.Examples(i18n.T(`
# List all pods in ps output format.
kubectl get pods
@ -87,7 +87,7 @@ var (
kubectl get rc/web service/frontend pods/web-pod-13je7
# List all resources with different types.
kubectl get all`)
kubectl get all`))
)
// NewCmdGet creates a command object for the generic "get" action, which

View File

@ -27,9 +27,9 @@ import (
"k8s.io/kubernetes/pkg/util/i18n"
)
var help_long = templates.LongDesc(`
var help_long = templates.LongDesc(i18n.T(`
Help provides help for any command in the application.
Simply type kubectl help [path to command] for full details.`)
Simply type kubectl help [path to command] for full details.`))
func NewCmdHelp(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{

View File

@ -67,14 +67,14 @@ type LabelOptions struct {
}
var (
label_long = templates.LongDesc(`
label_long = templates.LongDesc(i18n.T(`
Update the labels on a resource.
* A label must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to %[1]d characters.
* If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error.
* If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.`)
* If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.`))
label_example = templates.Examples(`
label_example = templates.Examples(i18n.T(`
# Update pod 'foo' with the label 'unhealthy' and the value 'true'.
kubectl label pods foo unhealthy=true
@ -92,7 +92,7 @@ var (
# Update pod 'foo' by removing a label named 'bar' if it exists.
# Does not require the --overwrite flag.
kubectl label pods foo bar-`)
kubectl label pods foo bar-`))
)
func NewCmdLabel(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -37,7 +37,7 @@ import (
)
var (
logs_example = templates.Examples(`
logs_example = templates.Examples(i18n.T(`
# Return snapshot logs from pod nginx with only one container
kubectl logs nginx
@ -60,7 +60,7 @@ var (
kubectl logs job/hello
# Return snapshot logs from container nginx-1 of a deployment named nginx
kubectl logs deployment/nginx -c nginx-1`)
kubectl logs deployment/nginx -c nginx-1`))
selectorTail int64 = 10
)

View File

@ -26,9 +26,9 @@ import (
)
var (
options_example = templates.Examples(`
options_example = templates.Examples(i18n.T(`
# Print flags inherited by all commands
kubectl options`)
kubectl options`))
)
// NewCmdOptions implements the options command

View File

@ -56,14 +56,14 @@ type PatchOptions struct {
}
var (
patch_long = templates.LongDesc(`
patch_long = templates.LongDesc(i18n.T(`
Update field(s) of a resource using strategic merge patch
JSON and YAML formats are accepted.
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`)
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`))
patch_example = templates.Examples(`
patch_example = templates.Examples(i18n.T(`
# Partially update a node using strategic merge patch
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
@ -74,7 +74,7 @@ var (
kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
# Update a container's image using a json patch with positional arrays
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'`)
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'`))
)
func NewCmdPatch(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -50,7 +50,7 @@ type PortForwardOptions struct {
}
var (
portforward_example = templates.Examples(`
portforward_example = templates.Examples(i18n.T(`
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
kubectl port-forward mypod 5000 6000
@ -61,7 +61,7 @@ var (
kubectl port-forward mypod :5000
# Listen on a random port locally, forwarding to 5000 in the pod
kubectl port-forward mypod 0:5000`)
kubectl port-forward mypod 0:5000`))
)
func NewCmdPortForward(f cmdutil.Factory, cmdOut, cmdErr io.Writer) *cobra.Command {

View File

@ -33,7 +33,7 @@ import (
var (
default_port = 8001
proxy_long = templates.LongDesc(`
proxy_long = templates.LongDesc(i18n.T(`
To proxy all of the kubernetes api and nothing else, use:
$ kubectl proxy --api-prefix=/
@ -48,9 +48,9 @@ var (
$ kubectl proxy --api-prefix=/custom/
The above lets you 'curl localhost:8001/custom/api/v1/pods'`)
The above lets you 'curl localhost:8001/custom/api/v1/pods'`))
proxy_example = templates.Examples(`
proxy_example = templates.Examples(i18n.T(`
# Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/
kubectl proxy --port=8011 --www=./local/www/
@ -60,7 +60,7 @@ var (
# Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api
# This makes e.g. the pods api available at localhost:8001/k8s-api/v1/pods/
kubectl proxy --api-prefix=/k8s-api`)
kubectl proxy --api-prefix=/k8s-api`))
)
func NewCmdProxy(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -37,7 +37,7 @@ import (
)
var (
replace_long = templates.LongDesc(`
replace_long = templates.LongDesc(i18n.T(`
Replace a resource by filename or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the
@ -45,9 +45,9 @@ var (
$ kubectl get TYPE NAME -o yaml
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`)
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`))
replace_example = templates.Examples(`
replace_example = templates.Examples(i18n.T(`
# Replace a pod using the data in pod.json.
kubectl replace -f ./pod.json
@ -58,7 +58,7 @@ var (
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
# Force replace, delete and then re-create the resource
kubectl replace --force -f ./pod.json`)
kubectl replace --force -f ./pod.json`))
)
func NewCmdReplace(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -42,16 +42,16 @@ import (
)
var (
rollingUpdate_long = templates.LongDesc(`
rollingUpdate_long = templates.LongDesc(i18n.T(`
Perform a rolling update of the given ReplicationController.
Replaces the specified replication controller with a new replication controller by updating one pod at a time to use the
new PodTemplate. The new-controller.json must specify the same namespace as the
existing replication controller and overwrite at least one (common) label in its replicaSelector.
![Workflow](http://kubernetes.io/images/docs/kubectl_rollingupdate.svg)`)
![Workflow](http://kubernetes.io/images/docs/kubectl_rollingupdate.svg)`))
rollingUpdate_example = templates.Examples(`
rollingUpdate_example = templates.Examples(i18n.T(`
# Update pods of frontend-v1 using new replication controller data in frontend-v2.json.
kubectl rolling-update frontend-v1 -f frontend-v2.json
@ -66,7 +66,7 @@ var (
kubectl rolling-update frontend --image=image:v2
# Abort and reverse an existing rollout in progress (from frontend-v1 to frontend-v2).
kubectl rolling-update frontend-v1 frontend-v2 --rollback`)
kubectl rolling-update frontend-v1 frontend-v2 --rollback`))
)
var (

View File

@ -48,12 +48,12 @@ import (
)
var (
run_long = templates.LongDesc(`
run_long = templates.LongDesc(i18n.T(`
Create and run a particular image, possibly replicated.
Creates a deployment or job to manage the created container(s).`)
Creates a deployment or job to manage the created container(s).`))
run_example = templates.Examples(`
run_example = templates.Examples(i18n.T(`
# Start a single instance of nginx.
kubectl run nginx --image=nginx
@ -85,7 +85,7 @@ var (
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
# Start the cron job to compute π to 2000 places and print it out every 5 minutes.
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'`)
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'`))
)
func NewCmdRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {

View File

@ -38,6 +38,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)
func TestGetRestartPolicy(t *testing.T) {
@ -81,7 +82,7 @@ func TestGetRestartPolicy(t *testing.T) {
}
for _, test := range tests {
cmd := &cobra.Command{}
cmd.Flags().String("restart", "", "dummy restart flag")
cmd.Flags().String("restart", "", i18n.T("dummy restart flag)"))
cmd.Flags().Lookup("restart").Value.Set(test.input)
policy, err := getRestartPolicy(cmd, test.interactive)
if test.expectErr && err == nil {

View File

@ -31,16 +31,16 @@ import (
)
var (
scale_long = templates.LongDesc(`
scale_long = templates.LongDesc(i18n.T(`
Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-version is specified, it is validated before the
scale is attempted, and it is guaranteed that the precondition holds true when the
scale is sent to the server.`)
scale is sent to the server.`))
scale_example = templates.Examples(`
scale_example = templates.Examples(i18n.T(`
# Scale a replicaset named 'foo' to 3.
kubectl scale --replicas=3 rs/foo
@ -54,7 +54,7 @@ var (
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
# Scale job named 'cron' to 3.
kubectl scale --replicas=3 job/cron`)
kubectl scale --replicas=3 job/cron`))
)
// NewCmdScale returns a cobra command with the appropriate configuration and flags to run scale

View File

@ -28,16 +28,16 @@ import (
)
var (
stop_long = templates.LongDesc(`
stop_long = templates.LongDesc(i18n.T(`
Deprecated: Gracefully shut down a resource by name or filename.
The stop command is deprecated, all its functionalities are covered by delete command.
See 'kubectl delete --help' for more details.
Attempts to shut down and delete a resource that supports graceful termination.
If the resource is scalable it will be scaled to 0 before deletion.`)
If the resource is scalable it will be scaled to 0 before deletion.`))
stop_example = templates.Examples(`
stop_example = templates.Examples(i18n.T(`
# Shut down foo.
kubectl stop replicationcontroller foo
@ -48,7 +48,7 @@ var (
kubectl stop -f service.json
# Shut down all resources in the path/to/resources directory
kubectl stop -f path/to/resources`)
kubectl stop -f path/to/resources`))
)
func NewCmdStop(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -55,16 +55,16 @@ type TaintOptions struct {
}
var (
taint_long = templates.LongDesc(`
taint_long = templates.LongDesc(i18n.T(`
Update the taints on one or more nodes.
* A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect.
* The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to %[1]d characters.
* The value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to %[2]d characters.
* The effect must be NoSchedule, PreferNoSchedule or NoExecute.
* Currently taint can only apply to node.`)
* Currently taint can only apply to node.`))
taint_example = templates.Examples(`
taint_example = templates.Examples(i18n.T(`
# Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'.
# If a taint with that key and effect already exists, its value is replaced as specified.
kubectl taint nodes foo dedicated=special-user:NoSchedule
@ -73,7 +73,7 @@ var (
kubectl taint nodes foo dedicated:NoSchedule-
# Remove from node 'foo' all the taints with key 'dedicated'
kubectl taint nodes foo dedicated-`)
kubectl taint nodes foo dedicated-`))
)
func NewCmdTaint(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -30,12 +30,12 @@ import (
type TopOptions struct{}
var (
topLong = templates.LongDesc(`
topLong = templates.LongDesc(i18n.T(`
Display Resource (CPU/Memory/Storage) usage.
The top command allows you to see the resource consumption for nodes or pods.
This command requires Heapster to be correctly configured and working on the server. `)
This command requires Heapster to be correctly configured and working on the server. `))
)
func NewCmdTop(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {

View File

@ -57,17 +57,17 @@ func (o *HeapsterTopOptions) Bind(flags *pflag.FlagSet) {
}
var (
topNodeLong = templates.LongDesc(`
topNodeLong = templates.LongDesc(i18n.T(`
Display Resource (CPU/Memory/Storage) usage of nodes.
The top-node command allows you to see the resource consumption of nodes.`)
The top-node command allows you to see the resource consumption of nodes.`))
topNodeExample = templates.Examples(`
topNodeExample = templates.Examples(i18n.T(`
# Show metrics for all nodes
kubectl top node
# Show metrics for a given node
kubectl top node NODE_NAME`)
kubectl top node NODE_NAME`))
)
func NewCmdTopNode(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -50,15 +50,15 @@ type TopPodOptions struct {
const metricsCreationDelay = 2 * time.Minute
var (
topPodLong = templates.LongDesc(`
topPodLong = templates.LongDesc(i18n.T(`
Display Resource (CPU/Memory/Storage) usage of pods.
The 'top pod' command allows you to see the resource consumption of pods.
Due to the metrics pipeline delay, they may be unavailable for a few minutes
since pod creation.`)
since pod creation.`))
topPodExample = templates.Examples(`
topPodExample = templates.Examples(i18n.T(`
# Show metrics for all pods in the default namespace
kubectl top pod
@ -69,7 +69,7 @@ var (
kubectl top pod POD_NAME --containers
# Show metrics for the pods defined by label name=myLabel
kubectl top pod -l name=myLabel`)
kubectl top pod -l name=myLabel`))
)
func NewCmdTopPod(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -38,9 +38,9 @@ type Version struct {
}
var (
version_example = templates.Examples(`
version_example = templates.Examples(i18n.T(`
# Print the client and server versions for the current context
kubectl version`)
kubectl version`))
)
func NewCmdVersion(f cmdutil.Factory, out io.Writer) *cobra.Command {

View File

@ -58,7 +58,15 @@ def string_flag_replace(match, file, line_number):
STRING_FLAG_MATCH = MatchHandler('(\s+cmd\.Flags\(\).String\("[^"]*", "[^"]*", )"([^"]*)"\)', string_flag_replace)
def replace(filename, matchers):
def long_string_replace(match, file, line_number):
return '{}i18n.T({}){}'.format(match.group(1), match.group(2), match.group(3))
LONG_DESC_MATCH = MatchHandler('(LongDesc\()(`[^`]+`)([^\n]\n)', long_string_replace)
EXAMPLE_MATCH = MatchHandler('(Examples\()(`[^`]+`)([^\n]\n)', long_string_replace)
def replace(filename, matchers, multiline_matchers):
"""Given a file and a set of matchers, run those matchers
across the file and replace it with the results.
"""
@ -76,9 +84,22 @@ def replace(filename, matchers):
if not matched:
sys.stdout.write(line)
sys.stdout.flush()
with open(filename, 'r') as datafile:
content = datafile.read()
for matcher in multiline_matchers:
match = matcher.regex.search(content)
while match:
rep = matcher.replace_fn(match, filename, 0)
# Escape back references in the replacement string
# (And escape for Python)
# (And escape for regex)
rep = re.sub('\\\\(\\d)', '\\\\\\\\\\1', rep)
content = matcher.regex.sub(rep, content, 1)
match = matcher.regex.search(content)
sys.stdout.write(content)
# gofmt the file again
from subprocess import call
call(["goimports", "-w", filename])
replace(sys.argv[1], [SHORT_MATCH, IMPORT_MATCH, STRING_FLAG_MATCH])
replace(sys.argv[1], [SHORT_MATCH, IMPORT_MATCH, STRING_FLAG_MATCH], [LONG_DESC_MATCH, EXAMPLE_MATCH])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff