@@ -28,7 +28,7 @@ import (
28
28
"github.com/codefresh-io/cli-v2/pkg/util"
29
29
apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
30
30
eventsutil "github.com/codefresh-io/cli-v2/pkg/util/events"
31
- ingressutil "github.com/codefresh-io/cli-v2/pkg/util/ingress "
31
+ routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing "
32
32
wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
33
33
34
34
"github.com/Masterminds/semver/v3"
@@ -50,7 +50,6 @@ import (
50
50
"github.com/juju/ansiterm"
51
51
"github.com/spf13/cobra"
52
52
corev1 "k8s.io/api/core/v1"
53
- netv1 "k8s.io/api/networking/v1"
54
53
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55
54
"k8s.io/apimachinery/pkg/util/intstr"
56
55
)
@@ -67,9 +66,12 @@ type (
67
66
HostName string
68
67
IngressHost string
69
68
IngressClass string
70
- IngressController ingressutil.IngressController
69
+ IngressController routingutil.RoutingController
70
+ GatewayName string
71
+ GatewayNamespace string
71
72
Flow string
72
73
GitProvider cfgit.Provider
74
+ useGatewayAPI bool
73
75
}
74
76
75
77
GitSourceDeleteOptions struct {
@@ -102,7 +104,10 @@ type (
102
104
hostName string
103
105
ingressHost string
104
106
ingressClass string
105
- ingressController ingressutil.IngressController
107
+ ingressController routingutil.RoutingController
108
+ gatewayName string
109
+ gatewayNamespace string
110
+ useGatewayAPI bool
106
111
}
107
112
108
113
dirConfig struct {
@@ -611,6 +616,9 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
611
616
ingressHost : opts .IngressHost ,
612
617
ingressClass : opts .IngressClass ,
613
618
ingressController : opts .IngressController ,
619
+ gatewayName : opts .GatewayName ,
620
+ gatewayNamespace : opts .GatewayNamespace ,
621
+ useGatewayAPI : opts .useGatewayAPI ,
614
622
})
615
623
if err != nil {
616
624
return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
@@ -746,9 +754,17 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
746
754
func createDemoGitPipeline (opts * gitSourceGitDemoPipelineOptions ) error {
747
755
if ! store .Get ().SkipIngress {
748
756
// Create an ingress that will manage external access to the git eventsource service
749
- ingress := createDemoPipelinesIngress (opts .ingressClass , opts .hostName , opts .ingressController , opts .runtimeName )
750
- ingressFilePath := store .Get ().DemoPipelinesIngressFileName
751
- if err := writeObjectToYaml (opts .gsFs , ingressFilePath , & ingress , cleanUpFieldsIngress ); err != nil {
757
+ routeOpts := routingutil.CreateRouteOpts {
758
+ RuntimeName : opts .runtimeName ,
759
+ IngressClass : opts .ingressClass ,
760
+ Hostname : opts .hostName ,
761
+ IngressController : opts .ingressController ,
762
+ GatewayName : opts .gatewayName ,
763
+ GatewayNamespace : opts .gatewayNamespace ,
764
+ }
765
+ routeName , route := routingutil .CreateDemoPipelinesRoute (& routeOpts , opts .useGatewayAPI )
766
+ routeFilePath := fmt .Sprintf ("%s.%s.yaml" , store .Get ().DemoPipelinesIngressObjectName , routeName )
767
+ if err := writeObjectToYaml (opts .gsFs , routeFilePath , & route , cleanUpFieldsIngress ); err != nil {
752
768
return fmt .Errorf ("failed to write yaml of demo pipeline ingress. Error: %w" , err )
753
769
}
754
770
}
@@ -823,26 +839,6 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
823
839
return nil
824
840
}
825
841
826
- func createDemoPipelinesIngress (ingressClass string , hostName string , ingressController ingressutil.IngressController , runtimeName string ) * netv1.Ingress {
827
- ingressOptions := ingressutil.CreateIngressOptions {
828
- Name : store .Get ().DemoPipelinesIngressObjectName ,
829
- IngressClassName : ingressClass ,
830
- Host : hostName ,
831
- Paths : []ingressutil.IngressPath {
832
- {
833
- Path : util .GenerateIngressPathForDemoGitEventSource (runtimeName ),
834
- ServiceName : store .Get ().DemoGitEventSourceObjectName + "-eventsource-svc" ,
835
- ServicePort : store .Get ().DemoGitEventSourceServicePort ,
836
- PathType : netv1 .PathTypePrefix ,
837
- },
838
- }}
839
-
840
- ingress := ingressutil .CreateIngress (& ingressOptions )
841
- ingressController .Decorate (ingress )
842
-
843
- return ingress
844
- }
845
-
846
842
func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
847
843
name := store .Get ().DemoGitEventSourceObjectName
848
844
es := createDemoEventSource (name )
@@ -1256,8 +1252,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
1256
1252
}
1257
1253
}
1258
1254
1259
- func cleanUpFieldsIngress (ingress * * netv1. Ingress ) (map [string ]interface {}, error ) {
1260
- crd , err := util .StructToMap (ingress )
1255
+ func cleanUpFieldsIngress (resource * interface {} ) (map [string ]interface {}, error ) {
1256
+ crd , err := util .StructToMap (resource )
1261
1257
if err != nil {
1262
1258
return nil , err
1263
1259
}
0 commit comments