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

Function PromptMissing

pkg/cmd/account/gcp/create/create.go:149–203  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

147}
148
149func PromptMissing(opts *CreateOptions) error {
150 if opts.Name.Value == "" {
151 if err := opts.Ask(&survey.Input{
152 Message: "Name",
153 Help: "A short, memorable, unique name for this account.",
154 }, &opts.Name.Value, survey.WithValidator(survey.ComposeValidators(
155 survey.MaxLength(200),
156 survey.MinLength(1),
157 survey.Required,
158 ))); err != nil {
159 return err
160 }
161 }
162
163 if opts.Description.Value == "" {
164 if err := opts.Ask(&surveyext.OctoEditor{
165 Editor: &survey.Editor{
166 Message: "Description",
167 Help: "A summary explaining the use of the account to other users.",
168 FileName: "*.md",
169 },
170 Optional: true,
171 }, &opts.Description.Value); err != nil {
172 return err
173 }
174 }
175
176 if len(opts.KeyFileData) == 0 {
177 if err := opts.Ask(&survey.Input{
178 Message: "Key File Path",
179 Help: "Path to the json key file to use when authenticating against Google Cloud.",
180 }, &opts.KeyFilePath.Value, survey.WithValidator(survey.ComposeValidators(
181 survey.Required,
182 validation.IsExistingFile,
183 ))); err != nil {
184 return err
185 }
186 data, err := os.ReadFile(opts.KeyFilePath.Value)
187 if err != nil {
188 return err
189 }
190 opts.KeyFileData = data
191 }
192
193 if opts.Environments.Value == nil {
194 envs, err := selectors.EnvironmentsMultiSelect(opts.Ask, opts.GetAllEnvironmentsCallback,
195 "Choose the environments that are allowed to use this account.\n"+
196 output.Dim("If nothing is selected, the account can be used for deployments to any environment."), false)
197 if err != nil {
198 return err
199 }
200 opts.Environments.Value = util.SliceTransform(envs, func(e *environments.Environment) string { return e.ID })
201 }
202 return nil
203}

Callers 2

CreateRunFunction · 0.70

Calls 4

EnvironmentsMultiSelectFunction · 0.92
DimFunction · 0.92
SliceTransformFunction · 0.92
AskMethod · 0.65

Tested by 1