()
| 36 | } |
| 37 | |
| 38 | func (cmd *CopySourceCommand) ValidateFlags() error { |
| 39 | if cmd.Organization != "" && cmd.Space == "" { |
| 40 | return translatableerror.RequiredFlagsError{ |
| 41 | Arg1: "--organization, -o", |
| 42 | Arg2: "--space, -s", |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if cmd.NoRestart && cmd.Strategy.Name != constant.DeploymentStrategyDefault { |
| 47 | return translatableerror.ArgumentCombinationError{ |
| 48 | Args: []string{"--no-restart", "--strategy"}, |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if cmd.NoRestart && cmd.NoWait { |
| 53 | return translatableerror.ArgumentCombinationError{ |
| 54 | Args: []string{"--no-restart", "--no-wait"}, |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | if cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil { |
| 59 | return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} |
| 60 | } |
| 61 | |
| 62 | if cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1 { |
| 63 | return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} |
| 64 | } |
| 65 | |
| 66 | if cmd.Strategy.Name != constant.DeploymentStrategyCanary && cmd.InstanceSteps != "" { |
| 67 | return translatableerror.RequiredFlagsError{Arg1: "--instance-steps", Arg2: "--strategy=canary"} |
| 68 | } |
| 69 | |
| 70 | if len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps) { |
| 71 | return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} |
| 72 | } |
| 73 | |
| 74 | if len(cmd.InstanceSteps) > 0 { |
| 75 | return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") |
| 76 | } |
| 77 | |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | func (cmd *CopySourceCommand) Setup(config command.Config, ui command.UI) error { |
| 82 | err := cmd.BaseCommand.Setup(config, ui) |
no test coverage detected