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

Function PromptMissing

pkg/cmd/account/ssh/create/create.go:158–232  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

156}
157
158func PromptMissing(opts *CreateOptions) error {
159 if opts.Name.Value == "" {
160 if err := opts.Ask(&survey.Input{
161 Message: "Name",
162 Help: "A short, memorable, unique name for this account.",
163 }, &opts.Name.Value, survey.WithValidator(survey.ComposeValidators(
164 survey.MaxLength(200),
165 survey.MinLength(1),
166 survey.Required,
167 ))); err != nil {
168 return err
169 }
170 }
171
172 if opts.Description.Value == "" {
173 if err := opts.Ask(&surveyext.OctoEditor{
174 Editor: &survey.Editor{
175 Message: "Description",
176 Help: "A summary explaining the use of the account to other users.",
177 FileName: "*.md",
178 },
179 Optional: true,
180 }, &opts.Description.Value); err != nil {
181 return err
182 }
183 }
184
185 if opts.Username.Value == "" {
186 if err := opts.Ask(&survey.Input{
187 Message: "Username",
188 Help: "The username to use when authenticating against the remote host.",
189 }, &opts.Username.Value, survey.WithValidator(survey.ComposeValidators(
190 survey.Required,
191 ))); err != nil {
192 return err
193 }
194 }
195
196 if len(opts.KeyFileData) == 0 {
197 if err := opts.Ask(&survey.Input{
198 Message: "Private Key File Path",
199 Help: "Path to the the private key file portion of the key pair.",
200 }, &opts.KeyFilePath.Value, survey.WithValidator(survey.ComposeValidators(
201 survey.Required,
202 validation.IsExistingFile,
203 ))); err != nil {
204 return err
205 }
206 data, err := os.ReadFile(opts.KeyFilePath.Value)
207 if err != nil {
208 return err
209 }
210 opts.KeyFileData = data
211 }
212
213 if opts.Passphrase.Value == "" {
214 if err := opts.Ask(&survey.Password{
215 Message: "Passphrase",

Callers 2

CreateRunFunction · 0.70

Calls 4

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

Tested by 1