Showing with 870 additions and 565 deletions.
  1. +5 −0 Godeps/Godeps.json
  2. +29 −0 Godeps/LICENSES
  3. +9 −7 docs/devel/kubectl-conventions.md
  4. +25 −23 pkg/kubectl/cmd/annotate.go
  5. +13 −9 pkg/kubectl/cmd/apply.go
  6. +10 −8 pkg/kubectl/cmd/attach.go
  7. +12 −8 pkg/kubectl/cmd/autoscale.go
  8. +13 −8 pkg/kubectl/cmd/config/create_authinfo.go
  9. +12 −9 pkg/kubectl/cmd/config/create_cluster.go
  10. +8 −5 pkg/kubectl/cmd/config/create_context.go
  11. +7 −4 pkg/kubectl/cmd/config/current_context.go
  12. +5 −3 pkg/kubectl/cmd/config/set.go
  13. +4 −2 pkg/kubectl/cmd/config/unset.go
  14. +10 −7 pkg/kubectl/cmd/config/view.go
  15. +22 −17 pkg/kubectl/cmd/convert.go
  16. +10 −7 pkg/kubectl/cmd/create.go
  17. +18 −15 pkg/kubectl/cmd/create_configmap.go
  18. +7 −5 pkg/kubectl/cmd/create_namespace.go
  19. +39 −35 pkg/kubectl/cmd/create_secret.go
  20. +7 −5 pkg/kubectl/cmd/create_serviceaccount.go
  21. +24 −21 pkg/kubectl/cmd/delete.go
  22. +25 −21 pkg/kubectl/cmd/describe.go
  23. +44 −33 pkg/kubectl/cmd/drain.go
  24. +32 −29 pkg/kubectl/cmd/edit.go
  25. +10 −8 pkg/kubectl/cmd/exec.go
  26. +10 −7 pkg/kubectl/cmd/explain.go
  27. +30 −27 pkg/kubectl/cmd/expose.go
  28. +24 −21 pkg/kubectl/cmd/get.go
  29. +21 −18 pkg/kubectl/cmd/label.go
  30. +13 −11 pkg/kubectl/cmd/logs.go
  31. +16 −13 pkg/kubectl/cmd/patch.go
  32. +11 −10 pkg/kubectl/cmd/portforward.go
  33. +21 −18 pkg/kubectl/cmd/proxy.go
  34. +17 −14 pkg/kubectl/cmd/replace.go
  35. +20 −17 pkg/kubectl/cmd/rollingupdate.go
  36. +11 −7 pkg/kubectl/cmd/rollout/rollout.go
  37. +9 −6 pkg/kubectl/cmd/rollout/rollout_history.go
  38. +12 −9 pkg/kubectl/cmd/rollout/rollout_pause.go
  39. +10 −7 pkg/kubectl/cmd/rollout/rollout_resume.go
  40. +7 −4 pkg/kubectl/cmd/rollout/rollout_status.go
  41. +9 −6 pkg/kubectl/cmd/rollout/rollout_undo.go
  42. +26 −23 pkg/kubectl/cmd/run.go
  43. +19 −16 pkg/kubectl/cmd/scale.go
  44. +6 −4 pkg/kubectl/cmd/set/set.go
  45. +14 −11 pkg/kubectl/cmd/set/set_image.go
  46. +17 −14 pkg/kubectl/cmd/stop.go
  47. +16 −13 pkg/kubectl/cmd/taint.go
  48. +11 −0 vendor/github.com/renstrom/dedent/.travis.yml
  49. +21 −0 vendor/github.com/renstrom/dedent/LICENSE
  50. +50 −0 vendor/github.com/renstrom/dedent/README.md
  51. +49 −0 vendor/github.com/renstrom/dedent/dedent.go

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -279,15 +279,17 @@ type MineConfig struct {
mineLatest bool
}
const (
mineLong = `Some long description
for my command.`
var (
mineLong = dedent.Dedent(`
mine which is described here
with lots of details.`)
mineExample = ` # Run my command's first action
$ %[1]s first
mineExample = dedent.Dedent(`
# Run my command's first action
kubectl mine first_action
# Run my command's second action on latest stuff
$ %[1]s second --latest`
# Run my command's second action on latest stuff
kubectl mine second_action --flag`)
)
// NewCmdMine implements the kubectl mine command.
@@ -25,6 +25,7 @@ import (
"strings"

"github.com/golang/glog"
"github.com/renstrom/dedent"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
@@ -58,42 +59,43 @@ type AnnotateOptions struct {
recursive bool
}

const (
var (
annotate_resources = `
pod (po), service (svc), replicationcontroller (rc),
node (no), event (ev), componentstatuse (cs),
limitrange (limits), persistentvolume (pv), persistentvolumeclaim (pvc),
horizontalpodautoscaler (hpa), resourcequota (quota), secret
`
horizontalpodautoscaler (hpa), resourcequota (quota), secret`

annotate_long = `Update the annotations on one or more resources.
annotate_long = dedent.Dedent(`
Update the annotations on one or more resources.
An annotation is a key/value pair that can hold larger (compared to a label), and possibly not human-readable, data.
It is intended to store non-identifying auxiliary data, especially data manipulated by tools and system extensions.
If --overwrite is true, then existing annotations can be overwritten, otherwise attempting to overwrite an annotation 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.
An annotation is a key/value pair that can hold larger (compared to a label), and possibly not human-readable, data.
It is intended to store non-identifying auxiliary data, especially data manipulated by tools and system extensions.
If --overwrite is true, then existing annotations can be overwritten, otherwise attempting to overwrite an annotation 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.
Possible resources include (case insensitive):` + annotate_resources
Possible resources include (case insensitive):`) + annotate_resources

annotate_example = `# 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'
annotate_example = dedent.Dedent(`
# 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'
# Update a pod identified by type and name in "pod.json"
kubectl annotate -f pod.json description='my frontend'
# Update a pod identified by type and name in "pod.json"
kubectl annotate -f pod.json description='my frontend'
# Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value.
kubectl annotate --overwrite pods foo description='my frontend running nginx'
# Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value.
kubectl annotate --overwrite pods foo description='my frontend running nginx'
# Update all pods in the namespace
kubectl annotate pods --all description='my frontend running nginx'
# Update all pods in the namespace
kubectl annotate pods --all description='my frontend running nginx'
# Update pod 'foo' only if the resource is unchanged from version 1.
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
# Update pod 'foo' only if the resource is unchanged from version 1.
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
# Update pod 'foo' by removing an annotation named 'description' if it exists.
# Does not require the --overwrite flag.
kubectl annotate pods foo description-`
# Update pod 'foo' by removing an annotation named 'description' if it exists.
# Does not require the --overwrite flag.
kubectl annotate pods foo description-`)
)

func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
@@ -22,6 +22,7 @@ import (
"time"

"github.com/jonboulle/clockwork"
"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/api"
@@ -50,17 +51,20 @@ const (
triesBeforeBackOff = 1
)

const (
apply_long = `Apply a configuration to a resource by filename or stdin.
The 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'.
var (
apply_long = dedent.Dedent(`
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.`)

JSON and YAML formats are accepted.`
apply_example = `# Apply the configuration in pod.json to a pod.
kubectl apply -f ./pod.json
apply_example = dedent.Dedent(`
# Apply the configuration in pod.json to a pod.
kubectl apply -f ./pod.json
# Apply the JSON passed into stdin to a pod.
cat pod.json | kubectl apply -f -`
# Apply the JSON passed into stdin to a pod.
cat pod.json | kubectl apply -f -`)
)

func NewCmdApply(f *cmdutil.Factory, out io.Writer) *cobra.Command {
@@ -22,6 +22,7 @@ import (
"net/url"

"github.com/golang/glog"
"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/api"
@@ -35,16 +36,17 @@ import (
"k8s.io/kubernetes/pkg/util/term"
)

const (
attach_example = `# Get output from running pod 123456-7890, using the first container by default
kubectl attach 123456-7890
var (
attach_example = dedent.Dedent(`
# Get output from running pod 123456-7890, using the first container by default
kubectl attach 123456-7890
# Get output from ruby-container from pod 123456-7890
kubectl attach 123456-7890 -c ruby-container
# Get output from ruby-container from pod 123456-7890
kubectl attach 123456-7890 -c ruby-container
# 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 attach 123456-7890 -c ruby-container -i -t`
# 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 attach 123456-7890 -c ruby-container -i -t`)
)

func NewCmdAttach(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
@@ -20,6 +20,8 @@ import (
"fmt"
"io"

"github.com/renstrom/dedent"

"k8s.io/kubernetes/pkg/kubectl"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
@@ -35,17 +37,19 @@ type AutoscaleOptions struct {
Recursive bool
}

const (
autoscaleLong = `Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.
var (
autoscaleLong = dedent.Dedent(`
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.`
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.`)

autoscaleExample = `# Auto scale a deployment "foo", with the number of pods between 2 to 10, no target CPU utilization specfied so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10
autoscaleExample = dedent.Dedent(`
# Auto scale a deployment "foo", with the number of pods between 2 to 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 to 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80`
# Auto scale a replication controller "foo", with the number of pods between 1 to 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80`)
)

func NewCmdAutoscale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
@@ -24,6 +24,7 @@ import (
"path/filepath"
"strings"

"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
@@ -44,7 +45,9 @@ type createAuthInfoOptions struct {
embedCertData flag.Tristate
}

var create_authinfo_long = fmt.Sprintf(`Sets a user entry in kubeconfig
var (
create_authinfo_long = fmt.Sprintf(`
Sets a user entry in kubeconfig
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
@@ -59,15 +62,17 @@ Specifying a name that already exists will merge new fields on top of existing v
Bearer token and basic auth are mutually exclusive.
`, clientcmd.FlagCertFile, clientcmd.FlagKeyFile, clientcmd.FlagBearerToken, clientcmd.FlagUsername, clientcmd.FlagPassword)

const create_authinfo_example = `# Set only the "client-key" field on the "cluster-admin"
# entry, without touching other values:
kubectl config set-credentials cluster-admin --client-key=~/.kube/admin.key
create_authinfo_example = dedent.Dedent(`
# Set only the "client-key" field on the "cluster-admin"
# entry, without touching other values:
kubectl config set-credentials cluster-admin --client-key=~/.kube/admin.key
# Set basic auth for the "cluster-admin" entry
kubectl config set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
# Set basic auth for the "cluster-admin" entry
kubectl config set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
# Embed client certificate data in the "cluster-admin" entry
kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true`
# Embed client certificate data in the "cluster-admin" entry
kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true`)
)

func NewCmdConfigSetAuthInfo(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {
options := &createAuthInfoOptions{configAccess: configAccess}
@@ -23,6 +23,7 @@ import (
"io/ioutil"
"path/filepath"

"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
@@ -41,17 +42,19 @@ type createClusterOptions struct {
embedCAData flag.Tristate
}

const (
create_cluster_long = `Sets a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.`
create_cluster_example = `# Set only the server field on the e2e cluster entry without touching other values.
kubectl config set-cluster e2e --server=https://1.2.3.4
var (
create_cluster_long = dedent.Dedent(`
Sets a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.`)
create_cluster_example = dedent.Dedent(`
# Set only the server field on the e2e cluster entry without touching other values.
kubectl config set-cluster e2e --server=https://1.2.3.4
# Embed certificate authority data for the e2e cluster entry
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
# Embed certificate authority data for the e2e cluster entry
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
# Disable cert checking for the dev cluster entry
kubectl config set-cluster e2e --insecure-skip-tls-verify=true`
# Disable cert checking for the dev cluster entry
kubectl config set-cluster e2e --insecure-skip-tls-verify=true`)
)

func NewCmdConfigSetCluster(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {
@@ -21,6 +21,7 @@ import (
"fmt"
"io"

"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
@@ -36,11 +37,13 @@ type createContextOptions struct {
namespace util.StringFlag
}

const (
create_context_long = `Sets a context entry in kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields.`
create_context_example = `# Set the user field on the gce context entry without touching other values
kubectl config set-context gce --user=cluster-admin`
var (
create_context_long = dedent.Dedent(`
Sets a context entry in kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields.`)
create_context_example = dedent.Dedent(`
# Set the user field on the gce context entry without touching other values
kubectl config set-context gce --user=cluster-admin`)
)

func NewCmdConfigSetContext(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {
@@ -20,6 +20,7 @@ import (
"fmt"
"io"

"github.com/renstrom/dedent"
"github.com/spf13/cobra"

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
@@ -30,10 +31,12 @@ type CurrentContextOptions struct {
ConfigAccess clientcmd.ConfigAccess
}

const (
current_context_long = `Displays the current-context`
current_context_example = `# Display the current-context
kubectl config current-context`
var (
current_context_long = dedent.Dedent(`
Displays the current-context`)
current_context_example = dedent.Dedent(`
# Display the current-context
kubectl config current-context`)
)

func NewCmdConfigCurrentContext(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {