@@ -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 }
@@ -823,26 +839,6 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
823839 return nil
824840}
825841
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-
846842func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
847843 name := store .Get ().DemoGitEventSourceObjectName
848844 es := createDemoEventSource (name )
@@ -1256,8 +1252,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
12561252 }
12571253}
12581254
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 )
12611257 if err != nil {
12621258 return nil , err
12631259 }
0 commit comments