@@ -420,7 +420,24 @@ func getKubeContextNameFromUserSelect(cmd *cobra.Command, kubeContextName *strin
420
420
return nil
421
421
}
422
422
423
- func getIngressHostFromCluster (ctx context.Context , opts * RuntimeInstallOptions ) error {
423
+ func getIngressHostFromUserInput (ctx context.Context , opts * RuntimeInstallOptions , foundIngressHost string ) error {
424
+ ingressHostPrompt := promptui.Prompt {
425
+ Label : "Ingress host" ,
426
+ Default : foundIngressHost ,
427
+ Pointer : promptui .PipeCursor ,
428
+ }
429
+
430
+ ingressHostInput , err := ingressHostPrompt .Run ()
431
+ if err != nil {
432
+ return fmt .Errorf ("Prompt error: %w" , err )
433
+ }
434
+
435
+ opts .IngressHost = ingressHostInput
436
+
437
+ return nil
438
+ }
439
+
440
+ func setIngressHost (ctx context.Context , opts * RuntimeInstallOptions ) error {
424
441
log .G (ctx ).Info ("Retrieving ingress controller info from your cluster...\n " )
425
442
426
443
cs := opts .KubeFactory .KubernetesClientSetOrDie ()
@@ -429,27 +446,46 @@ func getIngressHostFromCluster(ctx context.Context, opts *RuntimeInstallOptions)
429
446
return fmt .Errorf ("failed to get ingress controller info from your cluster: %w" , err )
430
447
}
431
448
449
+ var foundIngressHost string
450
+
432
451
for _ , s := range ServicesList .Items {
433
- if s .ObjectMeta .Name == opts .IngressController {
452
+ if s .ObjectMeta .Name == opts .IngressController && s . Spec . Type == "LoadBalancer" {
434
453
ingress := s .Status .LoadBalancer .Ingress [0 ]
435
454
if ingress .Hostname != "" {
436
- opts .IngressHost = fmt .Sprintf ("https://%s" , ingress .Hostname )
455
+ foundIngressHost = fmt .Sprintf ("https://%s" , ingress .Hostname )
456
+ break
437
457
} else {
438
- opts .IngressHost = fmt .Sprintf ("https://%s" , ingress .IP )
458
+ foundIngressHost = fmt .Sprintf ("https://%s" , ingress .IP )
459
+ break
439
460
}
440
- break
461
+ }
462
+ }
463
+
464
+ if store .Get ().Silent {
465
+ log .G (ctx ).Warnf ("Using ingress host %s" , foundIngressHost )
466
+ opts .IngressHost = foundIngressHost
467
+ } else {
468
+ err = getIngressHostFromUserInput (ctx , opts , foundIngressHost )
469
+ if err != nil {
470
+ return err
441
471
}
442
472
}
443
473
444
474
if opts .IngressController == "" {
445
- return fmt .Errorf ("failed to fetch ingress host from the cluster. please make sure you have a nginx ingress controller installed properly " )
475
+ return fmt .Errorf ("please provide an ingress host via -- ingress-host or installation wizard " )
446
476
}
447
477
448
478
return nil
449
479
}
450
480
451
481
func checkIngressHostCertificate (ctx context.Context , ingress string ) (bool , error ) {
452
- var err error
482
+ match , err := regexp .MatchString ("http:" , ingress )
483
+ if err != nil {
484
+ return false , err
485
+ }
486
+ if match {
487
+ return true , nil
488
+ }
453
489
454
490
res , err := http .Get (ingress )
455
491
0 commit comments