From 7fc35e8eb5dccd47f28813742a6d50c1098ec552 Mon Sep 17 00:00:00 2001 From: kargakis Date: Thu, 16 Apr 2015 11:09:14 +0200 Subject: [PATCH] Bundle resize command --- pkg/cmd/cli/cli.go | 29 ++++++++++++++++------------- pkg/cmd/cli/cmd/wrappers.go | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/pkg/cmd/cli/cli.go b/pkg/cmd/cli/cli.go index 364bccb1387d..c619af0dbceb 100644 --- a/pkg/cmd/cli/cli.go +++ b/pkg/cmd/cli/cli.go @@ -62,30 +62,33 @@ func NewCommandCLI(name, fullName string) *cobra.Command { in := os.Stdin out := os.Stdout - cmds.AddCommand(cmd.NewCmdLogin(f, in, out)) + // Kubernetes wrappers + cmds.AddCommand(cmd.NewCmdGet(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdLog(fullName, f, out)) + cmds.AddCommand(applyToCreate(cmd.NewCmdCreate(fullName, f, out))) // Deprecate 'osc apply' with 'osc create' command. + cmds.AddCommand(cmd.NewCmdExec(fullName, f, os.Stdin, out, os.Stderr)) + cmds.AddCommand(cmd.NewCmdPortForward(fullName, f)) + cmds.AddCommand(cmd.NewCmdDescribe(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdProxy(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdResize(fullName, f, out)) + + // OpenShift-specific commands cmds.AddCommand(cmd.NewCmdProject(f, out)) + cmds.AddCommand(cmd.NewCmdLogin(f, in, out)) cmds.AddCommand(cmd.NewCmdNewApplication(fullName, f, out)) cmds.AddCommand(cmd.NewCmdStatus(fullName, f, out)) cmds.AddCommand(cmd.NewCmdStartBuild(fullName, f, out)) cmds.AddCommand(cmd.NewCmdCancelBuild(fullName, f, out)) cmds.AddCommand(cmd.NewCmdBuildLogs(fullName, f, out)) cmds.AddCommand(cmd.NewCmdRollback(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdGet(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdDescribe(fullName, f, out)) - // Deprecate 'osc apply' with 'osc create' command. - cmds.AddCommand(applyToCreate(cmd.NewCmdCreate(fullName, f, out))) cmds.AddCommand(cmd.NewCmdProcess(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdLog(fullName, f, out)) - cmds.AddCommand(cmd.NewCmdExec(fullName, f, os.Stdin, out, os.Stderr)) - cmds.AddCommand(cmd.NewCmdPortForward(fullName, f)) - cmds.AddCommand(cmd.NewCmdProxy(fullName, f, out)) + cmds.AddCommand(cmd.NewCmdConfig(fullName, "config")) + cmds.AddCommand(cmd.NewCmdOptions(f, out)) if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName)) } - cmds.AddCommand(cmd.NewCmdConfig(fullName, "config")) - cmds.AddCommand(cmd.NewCmdOptions(f, out)) return cmds } diff --git a/pkg/cmd/cli/cmd/wrappers.go b/pkg/cmd/cli/cmd/wrappers.go index 52c6725b3fdc..45a64a697d76 100644 --- a/pkg/cmd/cli/cmd/wrappers.go +++ b/pkg/cmd/cli/cmd/wrappers.go @@ -197,3 +197,24 @@ Examples: cmd.Long = fmt.Sprintf(longDesc, fullName) return cmd } + +func NewCmdResize(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { + cmd := cmd.NewCmdResize(f.Factory, out) + longDesc := `Set a new size for a Replication Controller. + +Resize also allows users to specify one or more preconditions for the resize action. +If --current-replicas or --resource-version is specified, it is validated before the +resize is attempted, and it is guaranteed that the precondition holds true when the +resize is sent to the server. + +Examples: + + # Resize replication controller named 'foo' to 3. + $ %[1]s resize --replicas=3 replicationcontrollers foo + + # If the replication controller named foo's current size is 2, resize foo to 3. + $ %[1]s resize --current-replicas=2 --replicas=3 replicationcontrollers foo +` + cmd.Long = fmt.Sprintf(longDesc, fullName) + return cmd +}