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

Function AskQuestions

pkg/cmd/release/create/create.go:416–645  ·  view source on GitHub ↗
(octopus *octopusApiClient.Client, stdout io.Writer, asker question.Asker, options *executor.TaskOptionsCreateRelease)

Source from the content-addressed store, hash-verified

414}
415
416func AskQuestions(octopus *octopusApiClient.Client, stdout io.Writer, asker question.Asker, options *executor.TaskOptionsCreateRelease) error {
417 if octopus == nil {
418 return cliErrors.NewArgumentNullOrEmptyError("octopus")
419 }
420 if asker == nil {
421 return cliErrors.NewArgumentNullOrEmptyError("asker")
422 }
423 if options == nil {
424 return cliErrors.NewArgumentNullOrEmptyError("options")
425 }
426 // Note: we don't get here at all if no-prompt is enabled, so we know we are free to ask questions
427
428 // Note on output: survey prints things; if the option is specified already from the command line,
429 // we should emulate that so there is always a line where you can see what the item was when specified on the command line,
430 // however if we support a "quiet mode" then we shouldn't emit those
431
432 var err error
433 var selectedProject *projects.Project
434 if options.ProjectName == "" {
435 selectedProject, err = selectors.Project("Select the project in which the release will be created", octopus, asker)
436 if err != nil {
437 return err
438 }
439 } else { // project name is already provided, fetch the object because it's needed for further questions
440 selectedProject, err = selectors.FindProject(octopus, options.ProjectName)
441 if err != nil {
442 return err
443 }
444 _, _ = fmt.Fprintf(stdout, "Project %s\n", output.Cyan(selectedProject.Name))
445 }
446 options.ProjectName = selectedProject.Name
447
448 // we always need the deployment process, so we can prompt for package version overrides (or know that there aren't any packages, so it doesn't matter)
449
450 var gitReferenceKey string
451 if selectedProject.PersistenceSettings.Type() == projects.PersistenceSettingsTypeVersionControlled {
452 // if there is no git reference specified, ask the server for the list and prompt.
453 // we leave GitCommit alone in interactive mode; we don't prompt, but if it was specified on the
454 // commandline we just pass it through untouched.
455
456 if options.GitReference == "" { // we need a git ref; ask for one
457 gitRef, err := selectGitReference(octopus, asker, selectedProject)
458 if err != nil {
459 return err
460 }
461 options.GitReference = gitRef.CanonicalName // e.g /refs/heads/main
462 } else {
463 // we need to go lookup the git reference
464 _, _ = fmt.Fprintf(stdout, "Git Reference %s\n", output.Cyan(options.GitReference))
465 }
466
467 // we could go and query the server and validate if the commit exists, is this worthwhile?
468 if options.GitCommit != "" {
469 _, _ = fmt.Fprintf(stdout, "Git Commit %s\n", output.Cyan(options.GitCommit))
470 }
471
472 if options.GitCommit != "" { // prefer a specific git commit if one was specified
473 gitReferenceKey = options.GitCommit

Calls 15

ProjectFunction · 0.92
FindProjectFunction · 0.92
CyanFunction · 0.92
ChannelFunction · 0.92
FindChannelFunction · 0.92
AskPackageOverrideLoopFunction · 0.92
selectGitReferenceFunction · 0.85
askVersionMetadataFunction · 0.85
askVersionFunction · 0.85