MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / deployRun

Function deployRun

pkg/cmd/release/deploy/deploy.go:200–374  ·  view source on GitHub ↗
(cmd *cobra.Command, f factory.Factory, flags *DeployFlags)

Source from the content-addressed store, hash-verified

198}
199
200func 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

Callers 1

NewCmdDeployFunction · 0.85

Calls 15

NewRequesterFunction · 0.92
ParseVariableStringArrayFunction · 0.92
SliceContainsAnyFunction · 0.92
ToVariableStringArrayFunction · 0.92
GenerateAutomationCmdFunction · 0.92
YellowFunction · 0.92
FindProjectFunction · 0.92
ProcessTasksFunction · 0.92
NewTaskFunction · 0.92
BluefFunction · 0.92
NewDeployFlagsFunction · 0.85

Tested by

no test coverage detected