@@ -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- routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing "
31+ ingressutil "github.com/codefresh-io/cli-v2/pkg/util/ingress "
3232 wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
3333
3434 "github.com/Masterminds/semver/v3"
@@ -50,6 +50,7 @@ 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"
5354 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5455 "k8s.io/apimachinery/pkg/util/intstr"
5556)
@@ -66,12 +67,9 @@ type (
6667 HostName string
6768 IngressHost string
6869 IngressClass string
69- IngressController routingutil.RoutingController
70- GatewayName string
71- GatewayNamespace string
70+ IngressController ingressutil.IngressController
7271 Flow string
7372 GitProvider cfgit.Provider
74- useGatewayAPI bool
7573 }
7674
7775 GitSourceDeleteOptions struct {
@@ -104,10 +102,7 @@ type (
104102 hostName string
105103 ingressHost string
106104 ingressClass string
107- ingressController routingutil.RoutingController
108- gatewayName string
109- gatewayNamespace string
110- useGatewayAPI bool
105+ ingressController ingressutil.IngressController
111106 }
112107
113108 dirConfig struct {
@@ -616,9 +611,6 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
616611 ingressHost : opts .IngressHost ,
617612 ingressClass : opts .IngressClass ,
618613 ingressController : opts .IngressController ,
619- gatewayName : opts .GatewayName ,
620- gatewayNamespace : opts .GatewayNamespace ,
621- useGatewayAPI : opts .useGatewayAPI ,
622614 })
623615 if err != nil {
624616 return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
@@ -754,17 +746,9 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
754746func createDemoGitPipeline (opts * gitSourceGitDemoPipelineOptions ) error {
755747 if ! store .Get ().SkipIngress {
756748 // Create an ingress that will manage external access to the git eventsource service
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 {
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 {
768752 return fmt .Errorf ("failed to write yaml of demo pipeline ingress. Error: %w" , err )
769753 }
770754 }
@@ -839,6 +823,26 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
839823 return nil
840824}
841825
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+
842846func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
843847 name := store .Get ().DemoGitEventSourceObjectName
844848 es := createDemoEventSource (name )
@@ -1252,8 +1256,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
12521256 }
12531257}
12541258
1255- func cleanUpFieldsIngress (resource * interface {} ) (map [string ]interface {}, error ) {
1256- crd , err := util .StructToMap (resource )
1259+ func cleanUpFieldsIngress (ingress * * netv1. Ingress ) (map [string ]interface {}, error ) {
1260+ crd , err := util .StructToMap (ingress )
12571261 if err != nil {
12581262 return nil , err
12591263 }
0 commit comments