72
72
RuntimeName string
73
73
RuntimeToken string
74
74
RuntimeStoreIV string
75
+ HostName string
75
76
IngressHost string
76
77
IngressClass string
77
78
IngressController string
@@ -222,6 +223,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
222
223
cmd .Flags ().BoolVar (& installationOpts .SkipClusterChecks , "skip-cluster-checks" , false , "Skips the cluster's checks" )
223
224
cmd .Flags ().DurationVar (& store .Get ().WaitTimeout , "wait-timeout" , store .Get ().WaitTimeout , "How long to wait for the runtime components to be ready" )
224
225
cmd .Flags ().StringVar (& gitIntegrationCreationOpts .APIURL , "provider-api-url" , "" , "Git provider API url" )
226
+ cmd .Flags ().BoolVar (& store .Get ().SkipIngress , "skip-ingress" , false , "Skips the creation of ingress resources" )
225
227
cmd .Flags ().BoolVar (& store .Get ().BypassIngressClassCheck , "bypass-ingress-class-check" , false , "Disables the ingress class check during pre-installation" )
226
228
227
229
installationOpts .InsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
@@ -406,7 +408,7 @@ func ensureIngressHost(cmd *cobra.Command, opts *RuntimeInstallOptions) error {
406
408
}
407
409
408
410
func ensureIngressClass (ctx context.Context , opts * RuntimeInstallOptions ) error {
409
- if store .Get ().BypassIngressClassCheck {
411
+ if store .Get ().BypassIngressClassCheck || store . Get (). SkipIngress {
410
412
return nil
411
413
}
412
414
@@ -507,22 +509,12 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
507
509
508
510
handleCliStep (reporter .InstallPhaseStart , "Runtime installation phase started" , nil , true )
509
511
510
- rt , err := runtime .Download (opts .Version , opts .RuntimeName )
511
- handleCliStep (reporter .InstallStepDownloadRuntimeDefinition , "Downloading runtime definition" , err , true )
512
+ rt , server , err := runtimeInstallPreparations (opts )
512
513
if err != nil {
513
- return fmt .Errorf ("failed to download runtime definition: %w" , err )
514
- }
515
-
516
- runtimeVersion := "v99.99.99"
517
- if rt .Spec .Version != nil { // in dev mode
518
- runtimeVersion = rt .Spec .Version .String ()
514
+ return err
519
515
}
520
516
521
- server , err := util .CurrentServer ()
522
- handleCliStep (reporter .InstallStepGetServerAddress , "Getting current server address" , err , true )
523
- if err != nil {
524
- return fmt .Errorf ("failed to get current server address: %w" , err )
525
- }
517
+ runtimeVersion := rt .Spec .Version .String ()
526
518
527
519
componentNames := getComponents (rt , opts )
528
520
@@ -585,6 +577,68 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
585
577
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create codefresh-cm: %w" , err ))
586
578
}
587
579
580
+ err = createRuntimeComponents (ctx , opts , rt )
581
+ if err != nil {
582
+ return err
583
+ }
584
+
585
+ err = createGitSources (ctx , opts )
586
+ if err != nil {
587
+ return err
588
+ }
589
+
590
+ timeoutErr := intervalCheckIsRuntimePersisted (ctx , opts .RuntimeName )
591
+ handleCliStep (reporter .InstallStepCompleteRuntimeInstallation , "Completing runtime installation" , timeoutErr , true )
592
+ if timeoutErr != nil {
593
+ return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to complete installation: %w" , timeoutErr ))
594
+ }
595
+
596
+ err = createGitIntegration (ctx , opts )
597
+ if err != nil {
598
+ return err
599
+ }
600
+
601
+ installationSuccessMsg := fmt .Sprintf ("Runtime '%s' installed successfully" , opts .RuntimeName )
602
+ skipIngressInfoMsg := fmt .Sprintf (
603
+ `To complete the installation:
604
+ 1. Configure your cluster's routing service with path to '/%s' and '%s'
605
+ 2. Create and register Git integration using the commands:
606
+ cf integration git add default --runtime %s --api-url %s
607
+ cf integration git register default --runtime %s --token <AUTHENTICATION_TOKEN>` ,
608
+ store .Get ().AppProxyIngressPath ,
609
+ store .Get ().GithubExampleEventSourceEndpointPath ,
610
+ opts .RuntimeName ,
611
+ opts .GitIntegrationCreationOpts .APIURL ,
612
+ opts .RuntimeName )
613
+
614
+ summaryArr = append (summaryArr , summaryLog {installationSuccessMsg , Info })
615
+ if store .Get ().SkipIngress {
616
+ summaryArr = append (summaryArr , summaryLog {skipIngressInfoMsg , Info })
617
+ }
618
+
619
+ log .G (ctx ).Infof (installationSuccessMsg )
620
+
621
+ return nil
622
+ }
623
+
624
+ func runtimeInstallPreparations (opts * RuntimeInstallOptions ) (* runtime.Runtime , string , error ) {
625
+ rt , err := runtime .Download (opts .Version , opts .RuntimeName )
626
+ handleCliStep (reporter .InstallStepDownloadRuntimeDefinition , "Downloading runtime definition" , err , true )
627
+ if err != nil {
628
+ return nil , "" , fmt .Errorf ("failed to download runtime definition: %w" , err )
629
+ }
630
+
631
+ server , err := util .CurrentServer ()
632
+ handleCliStep (reporter .InstallStepGetServerAddress , "Getting current server address" , err , true )
633
+ if err != nil {
634
+ return nil , "" , fmt .Errorf ("failed to get current server address: %w" , err )
635
+ }
636
+
637
+ return rt , server , nil
638
+ }
639
+
640
+ func createRuntimeComponents (ctx context.Context , opts * RuntimeInstallOptions , rt * runtime.Runtime ) error {
641
+ var err error
588
642
for _ , component := range rt .Spec .Components {
589
643
infoStr := fmt .Sprintf ("Creating component '%s'" , component .Name )
590
644
log .G (ctx ).Infof (infoStr )
@@ -606,13 +660,18 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
606
660
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to install components: %s" , err ))
607
661
}
608
662
663
+ return nil
664
+ }
665
+
666
+ func createGitSources (ctx context.Context , opts * RuntimeInstallOptions ) error {
609
667
gitSrcMessage := fmt .Sprintf ("Creating git source `%s`" , store .Get ().GitSourceName )
610
- err = RunGitSourceCreate (ctx , & GitSourceCreateOptions {
668
+ err : = RunGitSourceCreate (ctx , & GitSourceCreateOptions {
611
669
InsCloneOpts : opts .InsCloneOpts ,
612
670
GsCloneOpts : opts .GsCloneOpts ,
613
671
GsName : store .Get ().GitSourceName ,
614
672
RuntimeName : opts .RuntimeName ,
615
673
CreateDemoResources : opts .InstallDemoResources ,
674
+ HostName : opts .HostName ,
616
675
IngressHost : opts .IngressHost ,
617
676
IngressClass : opts .IngressClass ,
618
677
})
@@ -642,28 +701,30 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
642
701
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create `%s`: %w" , store .Get ().MarketplaceGitSourceName , err ))
643
702
}
644
703
645
- timeoutErr := intervalCheckIsRuntimePersisted (ctx , opts .RuntimeName )
646
- handleCliStep (reporter .InstallStepCompleteRuntimeInstallation , "Completing runtime installation" , timeoutErr , true )
647
- if timeoutErr != nil {
648
- return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to complete installation: %w" , timeoutErr ))
649
- }
704
+ return nil
705
+ }
706
+
707
+ func createGitIntegration (ctx context.Context , opts * RuntimeInstallOptions ) error {
708
+ var gitIntgErr error
709
+ var appendToLog bool
650
710
651
- gitIntgErr := addDefaultGitIntegration (ctx , opts .RuntimeName , opts .GitIntegrationCreationOpts )
652
- handleCliStep (reporter .InstallStepCreateDefaultGitIntegration , "Creating a default git integration" , gitIntgErr , true )
711
+ if ! store .Get ().SkipIngress {
712
+ gitIntgErr = addDefaultGitIntegration (ctx , opts .RuntimeName , opts .GitIntegrationCreationOpts )
713
+ appendToLog = true
714
+ }
715
+ handleCliStep (reporter .InstallStepCreateDefaultGitIntegration , "Creating a default git integration" , gitIntgErr , appendToLog )
653
716
if gitIntgErr != nil {
654
717
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to create default git integration: %w" , gitIntgErr ))
655
718
}
656
719
657
- gitIntgErr = registerUserToGitIntegration (ctx , opts .RuntimeName , opts .GitIntegrationRegistrationOpts )
658
- handleCliStep (reporter .InstallStepRegisterToDefaultGitIntegration , "Registering user to the default git integration" , gitIntgErr , true )
720
+ if ! store .Get ().SkipIngress {
721
+ gitIntgErr = registerUserToGitIntegration (ctx , opts .RuntimeName , opts .GitIntegrationRegistrationOpts )
722
+ }
723
+ handleCliStep (reporter .InstallStepRegisterToDefaultGitIntegration , "Registering user to the default git integration" , gitIntgErr , appendToLog )
659
724
if gitIntgErr != nil {
660
725
return util .DecorateErrorWithDocsLink (fmt .Errorf ("failed to register user to the default git integration: %w" , gitIntgErr ))
661
726
}
662
727
663
- installationSuccessMsg := fmt .Sprintf ("Runtime '%s' installed successfully" , opts .RuntimeName )
664
- summaryArr = append (summaryArr , summaryLog {installationSuccessMsg , Info })
665
- log .G (ctx ).Infof (installationSuccessMsg )
666
-
667
728
return nil
668
729
}
669
730
@@ -702,7 +763,7 @@ func registerUserToGitIntegration(ctx context.Context, runtime string, opts *apm
702
763
703
764
func installComponents (ctx context.Context , opts * RuntimeInstallOptions , rt * runtime.Runtime ) error {
704
765
var err error
705
- if opts .IngressHost != "" {
766
+ if opts .IngressHost != "" && ! store . Get (). SkipIngress {
706
767
if err = createWorkflowsIngress (ctx , opts , rt ); err != nil {
707
768
return fmt .Errorf ("failed to patch Argo-Workflows ingress: %w" , err )
708
769
}
@@ -1285,6 +1346,7 @@ func createWorkflowsIngress(ctx context.Context, opts *RuntimeInstallOptions, rt
1285
1346
Name : rt .Name + store .Get ().WorkflowsIngressName ,
1286
1347
Namespace : rt .Namespace ,
1287
1348
IngressClassName : opts .IngressClass ,
1349
+ Host : opts .HostName ,
1288
1350
Annotations : map [string ]string {
1289
1351
"ingress.kubernetes.io/protocol" : "https" ,
1290
1352
"ingress.kubernetes.io/rewrite-target" : "/$2" ,
@@ -1367,11 +1429,12 @@ func configureAppProxy(ctx context.Context, opts *RuntimeInstallOptions, rt *run
1367
1429
},
1368
1430
})
1369
1431
1370
- if opts .IngressHost != "" {
1432
+ if opts .IngressHost != "" && ! store . Get (). SkipIngress {
1371
1433
ingress := ingressutil .CreateIngress (& ingressutil.CreateIngressOptions {
1372
1434
Name : rt .Name + store .Get ().AppProxyIngressName ,
1373
1435
Namespace : rt .Namespace ,
1374
1436
IngressClassName : opts .IngressClass ,
1437
+ Host : opts .HostName ,
1375
1438
Paths : []ingressutil.IngressPath {
1376
1439
{
1377
1440
Path : fmt .Sprintf ("/%s" , store .Get ().AppProxyIngressPath ),
0 commit comments