@@ -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
}
@@ -825,26 +841,6 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
825
841
return nil
826
842
}
827
843
828
- func createDemoPipelinesIngress (ingressClass string , hostName string , ingressController ingressutil.IngressController , runtimeName string ) * netv1.Ingress {
829
- ingressOptions := ingressutil.CreateIngressOptions {
830
- Name : store .Get ().DemoPipelinesIngressObjectName ,
831
- IngressClassName : ingressClass ,
832
- Host : hostName ,
833
- Paths : []ingressutil.IngressPath {
834
- {
835
- Path : util .GenerateIngressPathForDemoGitEventSource (runtimeName ),
836
- ServiceName : store .Get ().DemoGitEventSourceObjectName + "-eventsource-svc" ,
837
- ServicePort : store .Get ().DemoGitEventSourceServicePort ,
838
- PathType : netv1 .PathTypePrefix ,
839
- },
840
- }}
841
-
842
- ingress := ingressutil .CreateIngress (& ingressOptions )
843
- ingressController .Decorate (ingress )
844
-
845
- return ingress
846
- }
847
-
848
844
func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
849
845
name := store .Get ().DemoGitEventSourceObjectName
850
846
es := createDemoEventSource (name )
@@ -1258,8 +1254,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
1258
1254
}
1259
1255
}
1260
1256
1261
- func cleanUpFieldsIngress (ingress * * netv1. Ingress ) (map [string ]interface {}, error ) {
1262
- crd , err := util .StructToMap (ingress )
1257
+ func cleanUpFieldsIngress (resource * interface {} ) (map [string ]interface {}, error ) {
1258
+ crd , err := util .StructToMap (resource )
1263
1259
if err != nil {
1264
1260
return nil , err
1265
1261
}
0 commit comments