Replace flag text with const (#1391)
This commit is contained in:
@@ -30,8 +30,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Create),
|
||||
}
|
||||
wrapper.SetFlags(createCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.CanaryNameFlag, flag.CanaryTriggerNameFlag, flag.CanaryNewFuncFlag, flag.CanaryOldFuncFlag},
|
||||
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.CanaryWeightIncrementFlag, flag.CanaryIncrementIntervalFlag, flag.CanaryFailureThresholdFlag},
|
||||
Required: []flag.Flag{flag.CanaryName, flag.CanaryTriggerName, flag.CanaryNewFunc, flag.CanaryOldFunc},
|
||||
Optional: []flag.Flag{flag.NamespaceFunction, flag.CanaryWeightIncrement, flag.CanaryIncrementInterval, flag.CanaryFailureThreshold},
|
||||
})
|
||||
|
||||
getCmd := &cobra.Command{
|
||||
@@ -41,8 +41,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Get),
|
||||
}
|
||||
wrapper.SetFlags(getCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.CanaryNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespaceCanaryFlag},
|
||||
Required: []flag.Flag{flag.CanaryName},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary},
|
||||
})
|
||||
|
||||
updateCmd := &cobra.Command{
|
||||
@@ -52,8 +52,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Update),
|
||||
}
|
||||
wrapper.SetFlags(updateCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.CanaryNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespaceCanaryFlag, flag.CanaryWeightIncrementFlag, flag.CanaryIncrementIntervalFlag, flag.CanaryFailureThresholdFlag},
|
||||
Required: []flag.Flag{flag.CanaryName},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary, flag.CanaryWeightIncrement, flag.CanaryIncrementInterval, flag.CanaryFailureThreshold},
|
||||
})
|
||||
|
||||
deleteCmd := &cobra.Command{
|
||||
@@ -63,8 +63,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Delete),
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.CanaryNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespaceCanaryFlag},
|
||||
Required: []flag.Flag{flag.CanaryName},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
@@ -75,7 +75,7 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(List),
|
||||
}
|
||||
wrapper.SetFlags(listCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.NamespaceCanaryFlag},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary},
|
||||
})
|
||||
|
||||
command := &cobra.Command{
|
||||
|
||||
@@ -36,36 +36,36 @@ type CreateSubCommand struct {
|
||||
canary *fv1.CanaryConfig
|
||||
}
|
||||
|
||||
func Create(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) complete(flags cli.Input) error {
|
||||
func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// canary configs can be created for functions in the same namespace
|
||||
|
||||
name := flags.String(flagkey.CanaryName)
|
||||
ht := flags.String(flagkey.CanaryHTTPTriggerName)
|
||||
newFunc := flags.String(flagkey.CanaryNewFunc)
|
||||
oldFunc := flags.String(flagkey.CanaryOldFunc)
|
||||
fnNs := flags.String(flagkey.NamespaceFunction)
|
||||
incrementStep := flags.Int(flagkey.CanaryWeightIncrement)
|
||||
failureThreshold := flags.Int(flagkey.CanaryFailureThreshold)
|
||||
incrementInterval := flags.String(flagkey.CanaryIncrementInterval)
|
||||
name := input.String(flagkey.CanaryName)
|
||||
ht := input.String(flagkey.CanaryHTTPTriggerName)
|
||||
newFunc := input.String(flagkey.CanaryNewFunc)
|
||||
oldFunc := input.String(flagkey.CanaryOldFunc)
|
||||
fnNs := input.String(flagkey.NamespaceFunction)
|
||||
incrementStep := input.Int(flagkey.CanaryWeightIncrement)
|
||||
failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
|
||||
incrementInterval := input.String(flagkey.CanaryIncrementInterval)
|
||||
|
||||
// check for time parsing
|
||||
_, err := time.ParseDuration(incrementInterval)
|
||||
@@ -128,7 +128,7 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) run(flags cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.CanaryConfigCreate(opts.canary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating canary config")
|
||||
|
||||
@@ -53,12 +53,12 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) complete(flags cli.Input) error {
|
||||
opts.namespace = flags.String(flagkey.NamespaceCanary)
|
||||
func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
opts.namespace = input.String(flagkey.NamespaceCanary)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
canaryCfgs, err := opts.client.CanaryConfigList(opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing canary config")
|
||||
|
||||
Reference in New Issue
Block a user