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

Function PromptMissing

pkg/cmd/project/variables/update/update.go:214–299  ·  view source on GitHub ↗
(opts *UpdateOptions)

Source from the content-addressed store, hash-verified

212}
213
214func PromptMissing(opts *UpdateOptions) error {
215 var project *projects.Project
216 var err error
217 if opts.Project.Value == "" {
218 project, err = projectSelector("You have not specified a Project. Please select one:", opts.GetAllProjectsCallback, opts.Ask)
219 if err != nil {
220 return nil
221 }
222 opts.Project.Value = project.GetName()
223 } else {
224 project, err = opts.GetProjectCallback(opts.Project.Value)
225 if err != nil {
226 return err
227 }
228 }
229
230 if project.IsVersionControlled && opts.GitRef.Value == "" {
231 if err := opts.Ask(&survey.Input{
232 Message: "GitRef",
233 Help: fmt.Sprintf("The GitRef where the variable is stored"),
234 }, &opts.GitRef.Value, survey.WithValidator(survey.ComposeValidators(
235 survey.MaxLength(200),
236 survey.MinLength(1),
237 survey.Required,
238 ))); err != nil {
239 return err
240 }
241 }
242
243 var projectVariables *variables.VariableSet
244 if opts.GitRef.Value != "" {
245 projectVariables, err = opts.GetProjectVariablesByGitRef(opts.Space.GetID(), project.GetID(), opts.GitRef.Value)
246 } else {
247 projectVariables, err = opts.GetProjectVariables(project.GetID())
248 }
249 if err != nil {
250 return err
251 }
252
253 var variable *variables.Variable
254 if opts.Id.Value != "" || opts.Name.Value != "" {
255 variable, err = getVariable(opts, project, projectVariables)
256 if err != nil {
257 variable, err = promptForVariable(opts, projectVariables)
258 if err != nil {
259 return err
260 }
261 }
262 opts.Id.Value = variable.GetID()
263 opts.Name.Value = variable.Name
264 } else {
265 variable, err = promptForVariable(opts, projectVariables)
266 opts.Id.Value = variable.GetID()
267 opts.Name.Value = variable.Name
268 }
269
270 if opts.Value.Value == "" {
271 var updateValue bool

Calls 7

SelectOptionsFunction · 0.92
getVariableFunction · 0.85
scopesProvidedFunction · 0.85
projectSelectorFunction · 0.70
promptForVariableFunction · 0.70
GetNameMethod · 0.65
AskMethod · 0.65