@@ -105,13 +105,14 @@ func askUserIfToInstallDemoResources(cmd *cobra.Command, sampleInstall *bool) er
105
105
106
106
_ , result , err := prompt .Run ()
107
107
if err != nil {
108
- return fmt . Errorf ( "Prompt error: %w" , err )
108
+ return err
109
109
}
110
110
111
111
if result == "No" {
112
112
* sampleInstall = false
113
113
}
114
114
}
115
+
115
116
return nil
116
117
}
117
118
@@ -152,9 +153,11 @@ func getRepoFromUserInput(cmd *cobra.Command) error {
152
153
}
153
154
repoInput , err := repoPrompt .Run ()
154
155
if err != nil {
155
- return fmt . Errorf ( "Prompt error: %w" , err )
156
+ return err
156
157
}
158
+
157
159
die (cmd .Flags ().Set ("repo" , repoInput ))
160
+
158
161
return nil
159
162
}
160
163
@@ -179,11 +182,14 @@ func getRuntimeNameFromUserInput(runtimeName *string) error {
179
182
Default : "codefresh" ,
180
183
Pointer : promptui .PipeCursor ,
181
184
}
185
+
182
186
runtimeNameInput , err := runtimeNamePrompt .Run ()
183
187
if err != nil {
184
- return fmt . Errorf ( "Prompt error: %w" , err )
188
+ return err
185
189
}
190
+
186
191
* runtimeName = runtimeNameInput
192
+
187
193
return nil
188
194
}
189
195
@@ -218,7 +224,7 @@ func getRuntimeNameFromUserSelect(ctx context.Context, runtimeName *string) erro
218
224
219
225
_ , result , err := prompt .Run ()
220
226
if err != nil {
221
- return fmt . Errorf ( "Prompt error: %w" , err )
227
+ return err
222
228
}
223
229
224
230
* runtimeName = result
@@ -241,7 +247,7 @@ func getIngressClassFromUserSelect(ctx context.Context, ingressClassNames []stri
241
247
242
248
_ , result , err := prompt .Run ()
243
249
if err != nil {
244
- return fmt . Errorf ( "Prompt error: %w" , err )
250
+ return err
245
251
}
246
252
247
253
* ingressClass = result
@@ -271,7 +277,7 @@ func ensureGitToken(cmd *cobra.Command, cloneOpts *git.CloneOptions, verify bool
271
277
}
272
278
273
279
if verify {
274
- err := cfgit .VerifyToken (cmd .Context (), cloneOpts .Provider , cloneOpts .Auth .Password )
280
+ err := cfgit .VerifyToken (cmd .Context (), cloneOpts .Provider , cloneOpts .Auth .Password , cfgit . RuntimeToken )
275
281
if err != nil {
276
282
return fmt .Errorf ("failed to verify git token: %w" , err )
277
283
}
@@ -282,23 +288,35 @@ func ensureGitToken(cmd *cobra.Command, cloneOpts *git.CloneOptions, verify bool
282
288
283
289
func ensureGitPAT (cmd * cobra.Command , opts * RuntimeInstallOptions ) error {
284
290
var err error
285
- if ! store .Get ().Silent {
286
- return getGitPATFromUserInput (cmd , opts )
291
+ tokenFromFlag := opts .GitIntegrationRegistrationOpts .Token
292
+
293
+ if tokenFromFlag == "" {
294
+ if ! store .Get ().Silent {
295
+ err = getGitPATFromUserInput (cmd , opts )
296
+ if err != nil {
297
+ return err
298
+ }
299
+ } else {
300
+ log .G (cmd .Context ()).Info ("Using runtime token as personal user token" )
301
+ opts .GitIntegrationRegistrationOpts .Token = opts .InsCloneOpts .Auth .Password
302
+ if err != nil {
303
+ return err
304
+ }
305
+ }
287
306
}
288
307
289
- opts .GitIntegrationRegistrationOpts .Token , err = cmd .Flags ().GetString ("git-token" )
290
- return err
308
+ return cfgit .VerifyToken (cmd .Context (), opts .InsCloneOpts .Provider , opts .GitIntegrationRegistrationOpts .Token , cfgit .PersonalToken )
291
309
}
292
310
293
311
func getGitPATFromUserInput (cmd * cobra.Command , opts * RuntimeInstallOptions ) error {
294
312
gitPATPrompt := promptui.Prompt {
295
- Label : "Enter your Personal Git Access Token (leave blank to use runtime token. Can be changed later )" ,
313
+ Label : "Personal git token for your user (skip to use runtime token)" ,
296
314
Mask : '*' ,
297
315
}
298
316
299
317
gitPAT , err := gitPATPrompt .Run ()
300
318
if err != nil {
301
- return fmt . Errorf ( "prompt error: %w" , err )
319
+ return err
302
320
}
303
321
304
322
if gitPAT == "" {
@@ -314,14 +332,16 @@ func getGitPATFromUserInput(cmd *cobra.Command, opts *RuntimeInstallOptions) err
314
332
315
333
func getGitTokenFromUserInput (cmd * cobra.Command ) error {
316
334
gitTokenPrompt := promptui.Prompt {
317
- Label : "Git provider api token" ,
335
+ Label : "Runtime git api token" ,
318
336
Mask : '*' ,
319
337
}
320
338
gitTokenInput , err := gitTokenPrompt .Run ()
321
339
if err != nil {
322
- return fmt . Errorf ( "Prompt error: %w" , err )
340
+ return err
323
341
}
342
+
324
343
die (cmd .Flags ().Set ("git-token" , gitTokenInput ))
344
+
325
345
return nil
326
346
}
327
347
@@ -361,7 +381,7 @@ func promptSummaryToUser(ctx context.Context, finalParameters map[string]string,
361
381
362
382
_ , result , err := prompt .Run ()
363
383
if err != nil {
364
- return false , fmt . Errorf ( "Prompt error: %w" , err )
384
+ return false , err
365
385
}
366
386
367
387
if result == "Yes" {
@@ -409,7 +429,7 @@ func getKubeContextNameFromUserSelect(cmd *cobra.Command, kubeContextName *strin
409
429
410
430
index , _ , err := prompt .Run ()
411
431
if err != nil {
412
- return fmt . Errorf ( "Prompt error: %w" , err )
432
+ return err
413
433
}
414
434
415
435
result := contextsIndex [index ]
@@ -429,7 +449,7 @@ func getIngressHostFromUserInput(ctx context.Context, opts *RuntimeInstallOption
429
449
430
450
ingressHostInput , err := ingressHostPrompt .Run ()
431
451
if err != nil {
432
- return fmt . Errorf ( "Prompt error: %w" , err )
452
+ return err
433
453
}
434
454
435
455
opts .IngressHost = ingressHostInput
@@ -471,7 +491,7 @@ func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
471
491
}
472
492
}
473
493
474
- if opts .IngressController == "" {
494
+ if opts .IngressHost == "" {
475
495
return fmt .Errorf ("please provide an ingress host via --ingress-host or installation wizard" )
476
496
}
477
497
@@ -558,7 +578,7 @@ func askUserIfToProceedWithInsecure(ctx context.Context) error {
558
578
559
579
_ , result , err := prompt .Run ()
560
580
if err != nil {
561
- return fmt . Errorf ( "Prompt error: %w" , err )
581
+ return err
562
582
}
563
583
564
584
if result == "Yes" {
0 commit comments