Skip to content

Commit 6c75fb9

Browse files
CR-9612 support nginx enterprise version controller (#263)
* support "nginx-ingress" controller * wip * wip * adjust ensureIngressClass to support controller types * code duplicate fix * create master and minions ingresses when using nginx enterprise * small logic fix * added logic to find community controller name * adjust paths to master ingress * small fix * added costumize health check to argocd-cm * refactoring * restore bootstrapSpecifier * refactoring * some error convention fixing * logic fix * add warning message to nginx-enterprise users, removed customized health check * bump
1 parent 797343d commit 6c75fb9

File tree

8 files changed

+185
-91
lines changed

8 files changed

+185
-91
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.266
1+
VERSION=v0.0.267
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/common.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ func isValidIngressHost(ingressHost string) (bool, error) {
8888
return regexp.MatchString(`^(http|https)://`, ingressHost)
8989
}
9090

91-
func getControllerName(s string) string {
92-
split := strings.Split(s, "/")
93-
return split[1]
94-
}
95-
9691
func askUserIfToInstallDemoResources(cmd *cobra.Command, sampleInstall *bool) error {
9792
if !store.Get().Silent && !cmd.Flags().Changed("demo-resources") {
9893
templates := &promptui.SelectTemplates{
@@ -206,7 +201,7 @@ func getRuntimeNameFromUserSelect(ctx context.Context, runtimeName *string) erro
206201
}
207202

208203
if len(runtimes) == 0 {
209-
return fmt.Errorf("No runtimes were found")
204+
return fmt.Errorf("no runtimes were found")
210205
}
211206

212207
runtimeNames := make([]string, len(runtimes))
@@ -448,6 +443,9 @@ func validateIngressHost(ingressHost string) error {
448443
}
449444

450445
func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
446+
var foundIngressHost string
447+
var foundHostName string
448+
451449
log.G(ctx).Info("Retrieving ingress controller info from your cluster...\n")
452450

453451
cs := opts.KubeFactory.KubernetesClientSetOrDie()
@@ -456,9 +454,6 @@ func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
456454
return fmt.Errorf("failed to get ingress controller info from your cluster: %w", err)
457455
}
458456

459-
var foundIngressHost string
460-
var foundHostName string
461-
462457
for _, s := range ServicesList.Items {
463458
if s.ObjectMeta.Name == opts.IngressController && s.Spec.Type == "LoadBalancer" {
464459
if len(s.Status.LoadBalancer.Ingress) > 0 {
@@ -479,10 +474,9 @@ func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
479474
}
480475

481476
if store.Get().Silent {
482-
log.G(ctx).Warnf("Using ingress host %s", foundIngressHost)
483477
opts.IngressHost = foundIngressHost
484478
} else {
485-
err = getIngressHostFromUserInput(ctx, opts, foundIngressHost)
479+
err := getIngressHostFromUserInput(ctx, opts, foundIngressHost)
486480
if err != nil {
487481
return err
488482
}

cmd/commands/git-source.go

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ import (
5252

5353
type (
5454
GitSourceCreateOptions struct {
55-
InsCloneOpts *git.CloneOptions
56-
GsCloneOpts *git.CloneOptions
57-
GsName string
58-
RuntimeName string
59-
CreateDemoResources bool
60-
Exclude string
61-
Include string
62-
HostName string
63-
IngressHost string
64-
IngressClass string
55+
InsCloneOpts *git.CloneOptions
56+
GsCloneOpts *git.CloneOptions
57+
GsName string
58+
RuntimeName string
59+
CreateDemoResources bool
60+
Exclude string
61+
Include string
62+
HostName string
63+
IngressHost string
64+
IngressClass string
65+
IngressControllerType ingressControllerType
6566
}
6667

6768
GitSourceDeleteOptions struct {
@@ -85,12 +86,13 @@ type (
8586
}
8687

8788
gitSourceGithubExampleOptions struct {
88-
runtimeName string
89-
gsCloneOpts *git.CloneOptions
90-
gsFs fs.FS
91-
hostName string
92-
ingressHost string
93-
ingressClass string
89+
runtimeName string
90+
gsCloneOpts *git.CloneOptions
91+
gsFs fs.FS
92+
hostName string
93+
ingressHost string
94+
ingressClass string
95+
ingressControllerType ingressControllerType
9496
}
9597

9698
dirConfig struct {
@@ -252,12 +254,13 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
252254
}
253255

254256
err = createGithubExamplePipeline(&gitSourceGithubExampleOptions{
255-
runtimeName: opts.RuntimeName,
256-
gsCloneOpts: opts.GsCloneOpts,
257-
gsFs: gsFs,
258-
hostName: opts.HostName,
259-
ingressHost: opts.IngressHost,
260-
ingressClass: opts.IngressClass,
257+
runtimeName: opts.RuntimeName,
258+
gsCloneOpts: opts.GsCloneOpts,
259+
gsFs: gsFs,
260+
hostName: opts.HostName,
261+
ingressHost: opts.IngressHost,
262+
ingressClass: opts.IngressClass,
263+
ingressControllerType: opts.IngressControllerType,
261264
})
262265
if err != nil {
263266
return fmt.Errorf("failed to create github example pipeline. Error: %w", err)
@@ -730,7 +733,7 @@ func createDemoWorkflowTemplate(gsFs fs.FS) error {
730733
func createGithubExamplePipeline(opts *gitSourceGithubExampleOptions) error {
731734
if !store.Get().SkipIngress {
732735
// Create an ingress that will manage external access to the github eventsource service
733-
ingress := createGithubExampleIngress(opts.ingressClass, opts.ingressHost, opts.hostName)
736+
ingress := createGithubExampleIngress(opts.ingressClass, opts.ingressHost, opts.hostName, opts.ingressControllerType)
734737
ingressFilePath := opts.gsFs.Join(opts.gsCloneOpts.Path(), store.Get().GithubExampleIngressFileName)
735738

736739
ingressRedundanded, err := cleanUpFieldsIngressGithub(&ingress)
@@ -783,8 +786,8 @@ func createGithubExamplePipeline(opts *gitSourceGithubExampleOptions) error {
783786
return nil
784787
}
785788

786-
func createGithubExampleIngress(ingressClass string, ingressHost string, hostName string) *netv1.Ingress {
787-
return ingressutil.CreateIngress(&ingressutil.CreateIngressOptions{
789+
func createGithubExampleIngress(ingressClass string, ingressHost string, hostName string, ingressControllerType ingressControllerType) *netv1.Ingress {
790+
ingressOptions := ingressutil.CreateIngressOptions{
788791
Name: store.Get().CodefreshDeliveryPipelines,
789792
IngressClassName: ingressClass,
790793
Host: hostName,
@@ -795,7 +798,15 @@ func createGithubExampleIngress(ingressClass string, ingressHost string, hostNam
795798
ServiceName: store.Get().GithubExampleEventSourceObjectName + "-eventsource-svc",
796799
ServicePort: store.Get().GithubExampleEventSourceServicePort,
797800
},
798-
}})
801+
}}
802+
803+
if ingressControllerType == IngressControllerNginxEnterprise {
804+
ingressOptions.Annotations = map[string]string{
805+
"nginx.org/mergeable-ingress-type": "minion",
806+
}
807+
}
808+
809+
return ingressutil.CreateIngress(&ingressOptions)
799810
}
800811

801812
func getRepoOwnerAndNameFromRepoURL(repoURL string) (owner string, name string) {

0 commit comments

Comments
 (0)