@@ -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
- routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing "
31
+ ingressutil "github.com/codefresh-io/cli-v2/pkg/util/ingress "
32
32
wfutil "github.com/codefresh-io/cli-v2/pkg/util/workflow"
33
33
34
34
"github.com/Masterminds/semver/v3"
@@ -50,6 +50,7 @@ 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"
53
54
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
54
55
"k8s.io/apimachinery/pkg/util/intstr"
55
56
)
@@ -66,12 +67,9 @@ type (
66
67
HostName string
67
68
IngressHost string
68
69
IngressClass string
69
- IngressController routingutil.RoutingController
70
- GatewayName string
71
- GatewayNamespace string
70
+ IngressController ingressutil.IngressController
72
71
Flow string
73
72
GitProvider cfgit.Provider
74
- useGatewayAPI bool
75
73
}
76
74
77
75
GitSourceDeleteOptions struct {
@@ -104,10 +102,7 @@ type (
104
102
hostName string
105
103
ingressHost string
106
104
ingressClass string
107
- ingressController routingutil.RoutingController
108
- gatewayName string
109
- gatewayNamespace string
110
- useGatewayAPI bool
105
+ ingressController ingressutil.IngressController
111
106
}
112
107
113
108
dirConfig struct {
@@ -616,9 +611,6 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
616
611
ingressHost : opts .IngressHost ,
617
612
ingressClass : opts .IngressClass ,
618
613
ingressController : opts .IngressController ,
619
- gatewayName : opts .GatewayName ,
620
- gatewayNamespace : opts .GatewayNamespace ,
621
- useGatewayAPI : opts .useGatewayAPI ,
622
614
})
623
615
if err != nil {
624
616
return fmt .Errorf ("failed to create github example pipeline. Error: %w" , err )
@@ -754,17 +746,9 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
754
746
func createDemoGitPipeline (opts * gitSourceGitDemoPipelineOptions ) error {
755
747
if ! store .Get ().SkipIngress {
756
748
// 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 {
768
752
return fmt .Errorf ("failed to write yaml of demo pipeline ingress. Error: %w" , err )
769
753
}
770
754
}
@@ -839,6 +823,26 @@ func createDemoBitbucketServerPipeline(opts *gitSourceGitDemoPipelineOptions) er
839
823
return nil
840
824
}
841
825
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
+
842
846
func createDemoGithubEventSource (repoURL string , ingressHost string , runtimeName string , gitProvider cfgit.Provider ) * eventsourcev1alpha1.EventSource {
843
847
name := store .Get ().DemoGitEventSourceObjectName
844
848
es := createDemoEventSource (name )
@@ -1252,8 +1256,8 @@ func getBitbucketServerRepoFromGitURL(url string) eventsourcev1alpha1.BitbucketS
1252
1256
}
1253
1257
}
1254
1258
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 )
1257
1261
if err != nil {
1258
1262
return nil , err
1259
1263
}
0 commit comments