refactor to move kubectl.cmd.Factory to kubect/cmd/util
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
|
||||
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -44,7 +44,7 @@ $ kubectl rolling-update frontend-v1 -f frontend-v2.json
|
||||
$ cat frontend-v2.json | kubectl rolling-update frontend-v1 -f -`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
|
||||
func NewCmdRollingUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "rolling-update OLD_CONTROLLER_NAME -f NEW_CONTROLLER_SPEC",
|
||||
// rollingupdate is deprecated.
|
||||
@@ -54,7 +54,7 @@ func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
|
||||
Example: rollingUpdate_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := RunRollingUpdate(f, out, cmd, args)
|
||||
util.CheckErr(err)
|
||||
cmdutil.CheckErr(err)
|
||||
},
|
||||
}
|
||||
cmd.Flags().String("update-period", updatePeriod, `Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
|
||||
@@ -64,20 +64,20 @@ func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
||||
func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) error {
|
||||
if os.Args[1] == "rollingupdate" {
|
||||
printDeprecationWarning("rolling-update", "rollingupdate")
|
||||
}
|
||||
|
||||
filename := util.GetFlagString(cmd, "filename")
|
||||
filename := cmdutil.GetFlagString(cmd, "filename")
|
||||
if len(filename) == 0 {
|
||||
return util.UsageError(cmd, "Must specify filename for new controller")
|
||||
return cmdutil.UsageError(cmd, "Must specify filename for new controller")
|
||||
}
|
||||
period := util.GetFlagDuration(cmd, "update-period")
|
||||
interval := util.GetFlagDuration(cmd, "poll-interval")
|
||||
timeout := util.GetFlagDuration(cmd, "timeout")
|
||||
period := cmdutil.GetFlagDuration(cmd, "update-period")
|
||||
interval := cmdutil.GetFlagDuration(cmd, "poll-interval")
|
||||
timeout := cmdutil.GetFlagDuration(cmd, "timeout")
|
||||
if len(args) != 1 {
|
||||
return util.UsageError(cmd, "Must specify the controller to update")
|
||||
return cmdutil.UsageError(cmd, "Must specify the controller to update")
|
||||
}
|
||||
oldName := args[0]
|
||||
|
||||
@@ -98,11 +98,11 @@ func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []stri
|
||||
}
|
||||
newRc, ok := obj.(*api.ReplicationController)
|
||||
if !ok {
|
||||
return util.UsageError(cmd, "%s does not specify a valid ReplicationController", filename)
|
||||
return cmdutil.UsageError(cmd, "%s does not specify a valid ReplicationController", filename)
|
||||
}
|
||||
newName := newRc.Name
|
||||
if oldName == newName {
|
||||
return util.UsageError(cmd, "%s cannot have the same name as the existing ReplicationController %s",
|
||||
return cmdutil.UsageError(cmd, "%s cannot have the same name as the existing ReplicationController %s",
|
||||
filename, oldName)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []stri
|
||||
}
|
||||
}
|
||||
if !hasLabel {
|
||||
return util.UsageError(cmd, "%s must specify a matching key with non-equal value in Selector for %s",
|
||||
return cmdutil.UsageError(cmd, "%s must specify a matching key with non-equal value in Selector for %s",
|
||||
filename, oldName)
|
||||
}
|
||||
// TODO: handle resizes during rolling update
|
||||
|
Reference in New Issue
Block a user