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

Function PromptForConfigAsCode

pkg/cmd/project/convert/convert.go:229–330  ·  view source on GitHub ↗
(opts *ConvertOptions)

Source from the content-addressed store, hash-verified

227}
228
229func PromptForConfigAsCode(opts *ConvertOptions) (cmd.Dependable, error) {
230 if opts.GitStorage.Value == "" {
231 selectedOption, err := selectors.SelectOptions(opts.Ask, "Select where to store the Git credentials", getGitStorageOptions)
232
233 if err != nil {
234 return nil, err
235 }
236 opts.GitStorage.Value = selectedOption.Value
237 }
238
239 if strings.EqualFold(opts.GitStorage.Value, GitStorageLibrary) {
240 err := promptLibraryGitCredentials(opts, opts.GetAllGitCredentialsCallback)
241 if err != nil {
242 return nil, err
243 }
244 } else {
245 err := promptProjectGitCredentials(opts)
246 if err != nil {
247 return nil, err
248 }
249 }
250
251 if opts.GitUrl.Value == "" {
252 if err := opts.Ask(&survey.Input{
253 Message: "Git URL",
254 Help: "The URL of the Git repository to store configuration.",
255 }, &opts.GitUrl.Value, survey.WithValidator(survey.ComposeValidators(
256 survey.MaxLength(200),
257 survey.Required,
258 ))); err != nil {
259 return nil, err
260 }
261 }
262
263 if opts.GitBasePath.Value == "" {
264 if err := opts.Ask(&survey.Input{
265 Message: "Git repository base path",
266 Help: fmt.Sprintf("The path in the repository where Config As Code settings are stored. Default value is '%s'.", DefaultBasePath),
267 Default: DefaultBasePath,
268 }, &opts.GitBasePath.Value, survey.WithValidator(survey.ComposeValidators(
269 survey.MaxLength(200),
270 ))); err != nil {
271 return nil, err
272 }
273 }
274
275 if opts.GitBranch.Value == "" {
276 if err := opts.Ask(&survey.Input{
277 Message: "Git branch",
278 Help: fmt.Sprintf("The default branch to use. Default value is '%s'.", DefaultBranch),
279 Default: DefaultBranch,
280 }, &opts.GitBranch.Value, survey.WithValidator(survey.ComposeValidators(
281 survey.MaxLength(200),
282 ))); err != nil {
283 return nil, err
284 }
285 }
286

Callers 1

PromptMissingFunction · 0.70

Calls 6

SelectOptionsFunction · 0.92
EmptyFunction · 0.92
isDefaultBranchProtectedFunction · 0.85
AskMethod · 0.65

Tested by

no test coverage detected