@@ -28,7 +28,7 @@ import (
2828 "github.com/codefresh-io/cli-v2/pkg/util"
2929 apu "github.com/codefresh-io/cli-v2/pkg/util/aputil"
3030 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 "
3232 wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
3333
3434 "github.com/Masterminds/semver/v3"
@@ -50,7 +50,6 @@ import (
5050 "github.com/juju/ansiterm"
5151 "github.com/spf13/cobra"
5252 corev1 "k8s.io/api/core/v1"
53- netv1 "k8s.io/api/networking/v1"
5453 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5554 "k8s.io/apimachinery/pkg/util/intstr"
5655)
@@ -67,9 +66,12 @@ type (
6766 HostName string
6867 IngressHost string
6968 IngressClass string
70- IngressController ingressutil.IngressController
69+ IngressController routingutil.RoutingController
70+ GatewayName string
71+ GatewayNamespace string
7172 Flow string
7273 GitProvider cfgit.Provider
74+ useGatewayAPI bool
7375 }
7476
7577 GitSourceDeleteOptions struct {
@@ -102,7 +104,10 @@ type (
102104 hostName string
103105 ingressHost string
104106 ingressClass string
105- ingressController ingressutil.IngressController
107+ ingressController routingutil.RoutingController
108+ gatewayName string
109+ gatewayNamespace string
110+ useGatewayAPI bool
106111 }
107112
108113 dirConfig struct {
@@ -611,6 +616,9 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
611616 ingressHost : opts .IngressHost ,
612617 ingressClass : opts .IngressClass ,
613618 ingressController : opts .IngressController ,
619+ gatewayName : opts .GatewayName ,
620+ gatewayNamespace : opts .GatewayNamespace ,
621+ useGatewayAPI : opts .useGatewayAPI ,
614622 })
615623 if err != nil {
616624 return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
@@ -746,9 +754,17 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
746754func createDemoGitPipeline (opts * gitSourceGitDemoPipelineOptions ) error {
747755 if ! store .Get ().SkipIngress {
748756 // 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 {
752768 return fmt .Errorf ("failed to write yaml of demo pipeline ingress. Error: %w" , err )
753769 }
754770 }
@@ -825,26 +841,6 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
825841 return nil
826842}
827843
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-
848844func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
849845 name := store .Get ().DemoGitEventSourceObjectName
850846 es := createDemoEventSource (name )
@@ -1258,8 +1254,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
12581254 }
12591255}
12601256
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 )
12631259 if err != nil {
12641260 return nil , err
12651261 }
0 commit comments