Commit 5836d455 authored by Alex Robinson's avatar Alex Robinson

Merge pull request #12239 from eparis/bash-completions-rolling-update

Bash completion annotations for rollingupdates
parents 057be1fc 9de64328
...@@ -469,7 +469,11 @@ _kubectl_rolling-update() ...@@ -469,7 +469,11 @@ _kubectl_rolling-update()
flags+=("--deployment-label-key=") flags+=("--deployment-label-key=")
flags+=("--dry-run") flags+=("--dry-run")
flags+=("--filename=") flags+=("--filename=")
flags_with_completion+=("--filename")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
two_word_flags+=("-f") two_word_flags+=("-f")
flags_with_completion+=("-f")
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--help") flags+=("--help")
flags+=("-h") flags+=("-h")
flags+=("--image=") flags+=("--image=")
...@@ -485,6 +489,9 @@ _kubectl_rolling-update() ...@@ -485,6 +489,9 @@ _kubectl_rolling-update()
flags+=("--update-period=") flags+=("--update-period=")
must_have_one_flag=() must_have_one_flag=()
must_have_one_flag+=("--filename=")
must_have_one_flag+=("-f")
must_have_one_flag+=("--image=")
must_have_one_noun=() must_have_one_noun=()
} }
......
...@@ -31,7 +31,7 @@ existing replication controller and overwrite at least one (common) label in its ...@@ -31,7 +31,7 @@ existing replication controller and overwrite at least one (common) label in its
If true, print out the changes that would be made, but don't actually make them. If true, print out the changes that would be made, but don't actually make them.
.PP .PP
\fB\-f\fP, \fB\-\-filename\fP="" \fB\-f\fP, \fB\-\-filename\fP=[]
Filename or URL to file to use to create the new replication controller. Filename or URL to file to use to create the new replication controller.
.PP .PP
......
...@@ -71,7 +71,7 @@ $ kubectl rolling-update frontend --image=image:v2 ...@@ -71,7 +71,7 @@ $ kubectl rolling-update frontend --image=image:v2
``` ```
--deployment-label-key="deployment": The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise --deployment-label-key="deployment": The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise
--dry-run[=false]: If true, print out the changes that would be made, but don't actually make them. --dry-run[=false]: If true, print out the changes that would be made, but don't actually make them.
-f, --filename="": Filename or URL to file to use to create the new replication controller. -f, --filename=[]: Filename or URL to file to use to create the new replication controller.
-h, --help[=false]: help for rolling-update -h, --help[=false]: help for rolling-update
--image="": Image to use for upgrading the replication controller. Can not be used with --filename/-f --image="": Image to use for upgrading the replication controller. Can not be used with --filename/-f
--no-headers[=false]: When using the default output, don't print headers. --no-headers[=false]: When using the default output, don't print headers.
...@@ -117,7 +117,7 @@ $ kubectl rolling-update frontend --image=image:v2 ...@@ -117,7 +117,7 @@ $ kubectl rolling-update frontend --image=image:v2
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-07 19:25:01.999165947 +0000 UTC ###### Auto generated by spf13/cobra at 2015-08-10 14:26:04.707001372 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS --> <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]() [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]()
......
...@@ -77,8 +77,11 @@ func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command { ...@@ -77,8 +77,11 @@ func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().Duration("update-period", updatePeriod, `Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`) cmd.Flags().Duration("update-period", updatePeriod, `Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
cmd.Flags().Duration("poll-interval", pollInterval, `Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`) cmd.Flags().Duration("poll-interval", pollInterval, `Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
cmd.Flags().Duration("timeout", timeout, `Max time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`) cmd.Flags().Duration("timeout", timeout, `Max time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
cmd.Flags().StringP("filename", "f", "", "Filename or URL to file to use to create the new replication controller.") usage := "Filename or URL to file to use to create the new replication controller."
kubectl.AddJsonFilenameFlag(cmd, usage)
cmd.MarkFlagRequired("filename")
cmd.Flags().String("image", "", "Image to use for upgrading the replication controller. Can not be used with --filename/-f") cmd.Flags().String("image", "", "Image to use for upgrading the replication controller. Can not be used with --filename/-f")
cmd.MarkFlagRequired("image")
cmd.Flags().String("deployment-label-key", "deployment", "The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise") cmd.Flags().String("deployment-label-key", "deployment", "The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise")
cmd.Flags().Bool("dry-run", false, "If true, print out the changes that would be made, but don't actually make them.") cmd.Flags().Bool("dry-run", false, "If true, print out the changes that would be made, but don't actually make them.")
cmd.Flags().Bool("rollback", false, "If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout") cmd.Flags().Bool("rollback", false, "If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout")
...@@ -88,16 +91,23 @@ func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command { ...@@ -88,16 +91,23 @@ func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
func validateArguments(cmd *cobra.Command, args []string) (deploymentKey, filename, image, oldName string, err error) { func validateArguments(cmd *cobra.Command, args []string) (deploymentKey, filename, image, oldName string, err error) {
deploymentKey = cmdutil.GetFlagString(cmd, "deployment-label-key") deploymentKey = cmdutil.GetFlagString(cmd, "deployment-label-key")
filename = cmdutil.GetFlagString(cmd, "filename")
image = cmdutil.GetFlagString(cmd, "image") image = cmdutil.GetFlagString(cmd, "image")
filenames := cmdutil.GetFlagStringSlice(cmd, "filename")
filename = ""
if len(deploymentKey) == 0 { if len(deploymentKey) == 0 {
return "", "", "", "", cmdutil.UsageError(cmd, "--deployment-label-key can not be empty") return "", "", "", "", cmdutil.UsageError(cmd, "--deployment-label-key can not be empty")
} }
if len(filename) == 0 && len(image) == 0 { if len(filenames) > 1 {
return "", "", "", "", cmdutil.UsageError(cmd, "May only specificy a single filename for new controller")
}
if len(filenames) > 0 {
filename = filenames[0]
}
if len(filenames) == 0 && len(image) == 0 {
return "", "", "", "", cmdutil.UsageError(cmd, "Must specify --filename or --image for new controller") return "", "", "", "", cmdutil.UsageError(cmd, "Must specify --filename or --image for new controller")
} }
if len(filename) != 0 && len(image) != 0 { if len(filenames) != 0 && len(image) != 0 {
return "", "", "", "", cmdutil.UsageError(cmd, "--filename and --image can not both be specified") return "", "", "", "", cmdutil.UsageError(cmd, "--filename and --image can not both be specified")
} }
if len(args) < 1 { if len(args) < 1 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment