(cmd *cobra.Command, f factory.Factory, flags *DeployFlags)
| 198 | } |
| 199 | |
| 200 | func deployRun(cmd *cobra.Command, f factory.Factory, flags *DeployFlags) error { |
| 201 | outputFormat, err := cmd.Flags().GetString(constants.FlagOutputFormat) |
| 202 | if err != nil { // should never happen, but fallback if it does |
| 203 | outputFormat = constants.OutputFormatTable |
| 204 | } |
| 205 | |
| 206 | octopus, err := f.GetSpacedClient(apiclient.NewRequester(cmd)) |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | |
| 211 | parsedVariables, err := executionscommon.ParseVariableStringArray(flags.Variables.Value) |
| 212 | if err != nil { |
| 213 | return err |
| 214 | } |
| 215 | |
| 216 | options := &executor.TaskOptionsDeployRelease{ |
| 217 | ProjectName: flags.Project.Value, |
| 218 | ReleaseVersion: flags.ReleaseVersion.Value, |
| 219 | Environments: flags.Environments.Value, |
| 220 | Tenants: flags.Tenants.Value, |
| 221 | TenantTags: flags.TenantTags.Value, |
| 222 | ScheduledStartTime: flags.DeployAt.Value, |
| 223 | ScheduledExpiryTime: flags.MaxQueueTime.Value, |
| 224 | ExcludedSteps: flags.ExcludedSteps.Value, |
| 225 | GuidedFailureMode: flags.GuidedFailureMode.Value, |
| 226 | ForcePackageDownload: flags.ForcePackageDownload.Value, |
| 227 | DeploymentTargets: flags.DeploymentTargets.Value, |
| 228 | ExcludeTargets: flags.ExcludeTargets.Value, |
| 229 | DeploymentFreezeNames: flags.DeploymentFreezeNames.Value, |
| 230 | DeploymentFreezeOverrideReason: flags.DeploymentFreezeOverrideReason.Value, |
| 231 | Variables: parsedVariables, |
| 232 | UpdateVariables: flags.UpdateVariables.Value, |
| 233 | } |
| 234 | |
| 235 | // special case for FlagForcePackageDownload bool so we can tell if it was set on the cmdline or missing |
| 236 | if cmd.Flags().Lookup(FlagForcePackageDownload).Changed { |
| 237 | options.ForcePackageDownloadWasSpecified = true |
| 238 | } |
| 239 | |
| 240 | if f.IsPromptEnabled() { |
| 241 | now := time.Now |
| 242 | if cmd.Context() != nil { // allow context to override the definition of 'now' for testing |
| 243 | if n, ok := cmd.Context().Value(constants.ContextKeyTimeNow).(func() time.Time); ok { |
| 244 | now = n |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | err = AskQuestions(octopus, cmd.OutOrStdout(), f.Ask, f.GetCurrentSpace(), options, now) |
| 249 | if err != nil { |
| 250 | return err |
| 251 | } |
| 252 | |
| 253 | if !constants.IsProgrammaticOutputFormat(outputFormat) { |
| 254 | // the Q&A process will have modified options;backfill into flags for generation of the automation cmd |
| 255 | resolvedFlags := NewDeployFlags() |
| 256 | resolvedFlags.Project.Value = options.ProjectName |
| 257 | resolvedFlags.ReleaseVersion.Value = options.ReleaseVersion |
no test coverage detected