Skip to content

Commit

Permalink
refactor: Simplify Git provider EventListeners and Ingress handling (#93
Browse files Browse the repository at this point in the history
)

Problem:
Creating separate EventListeners for each Git provider type results in
convoluted traffic management logic.

Solution:
Consolidate by assigning constant values to EventListener and Ingress names.

Additional Context:
Ensure codebase Operator code aligns with these updates.

JIRA: EPMDEDP-12939

Signed-off-by: Sergiy Kulanov <[email protected]>
Change-Id: I269c3efd061bf12268856f2635fd0b2c2a9c3d70
  • Loading branch information
SergK committed Jan 3, 2024
1 parent b7440b3 commit 78b63cb
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ data:
ct.yaml: |
validate-maintainers: {{ default "false" .Values.ctLint.validateMaintainers }}
chart_schema.yaml:{{ toYaml .Values.ctLint.chartSchema | nindent 4 }}
lintconf.yaml:{{ toYaml .Values.ctLint.lintconf | nindent 4 }}
lintconf.yaml:{{ toYaml .Values.ctLint.lintconf | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{{- if ne .Values.global.gitProvider "gerrit" -}}
{{ if eq .Values.global.platform "kubernetes" }}
{{- if .Values.eventListener.ingress.enabled }}
{{- $elName := printf "el-%s-listener" .Values.global.gitProvider -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $elName }}
name: event-listener
labels:
{{- include "edp-tekton.labels" . | nindent 4 }}
{{- with .Values.eventListener.ingress.annotations }}
Expand All @@ -24,16 +23,17 @@ spec:
{{- end }}
{{- end }}
rules:
- host: {{ $elName }}-{{ .Release.Namespace }}.{{ .Values.global.dnsWildCard }}
- host: el-{{ .Release.Namespace }}.{{ .Values.global.dnsWildCard }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $elName }}
# The service name will come from EventListener CR
name: edp
port:
number: 8080
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: gerrit-listener
name: edp
labels:
{{- include "edp-tekton.labels" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: github-listener
name: edp
labels:
{{- include "edp-tekton.labels" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: gitlab-listener
name: edp
labels:
{{- include "edp-tekton.labels" . | nindent 4 }}
spec:
Expand Down
12 changes: 6 additions & 6 deletions charts/pipelines-library/tests/test_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def test_ingress_for_gitlab_el():
gitProvider: gitlab
"""

el_Name = "el-gitlab-listener"
el_Name = "event-listener"
r = helm_template(config)

assert el_Name in r["ingress"]
assert "el-gitlab-listener-ns.example.com" in r["ingress"][el_Name]["spec"]["rules"][0]["host"]
assert el_Name in r["ingress"][el_Name]["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"]
assert "el-ns.example.com" in r["ingress"][el_Name]["spec"]["rules"][0]["host"]
assert "edp" in r["ingress"][el_Name]["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"]


def test_ingress_for_github_el():
Expand All @@ -44,12 +44,12 @@ def test_ingress_for_github_el():
gitProvider: github
"""

el_Name = "el-github-listener"
el_Name = "event-listener"
r = helm_template(config)

assert el_Name in r["ingress"]
assert "el-github-listener-ns.example.com" in r["ingress"][el_Name]["spec"]["rules"][0]["host"]
assert el_Name in r["ingress"][el_Name]["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"]
assert "el-ns.example.com" in r["ingress"][el_Name]["spec"]["rules"][0]["host"]
assert "edp" in r["ingress"][el_Name]["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]["name"]


def test_pruner_disabled():
Expand Down
4 changes: 2 additions & 2 deletions charts/pipelines-library/tests/test_github_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def test_github_is_enabled():

r = helm_template(config)

glb = r["eventlistener"]["github-listener"]["spec"]["triggers"][0]["interceptors"][0]["params"][0]["value"]
glr = r["eventlistener"]["github-listener"]["spec"]["triggers"][1]["interceptors"][0]["params"][0]["value"]
glb = r["eventlistener"]["edp"]["spec"]["triggers"][0]["interceptors"][0]["params"][0]["value"]
glr = r["eventlistener"]["edp"]["spec"]["triggers"][1]["interceptors"][0]["params"][0]["value"]
gitserver = r["gitserver"]["github"]["spec"]

assert "secretString" \
Expand Down
4 changes: 2 additions & 2 deletions charts/pipelines-library/tests/test_gitlab_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def test_gitlab_is_enabled():

r = helm_template(config)

glb = r["eventlistener"]["gitlab-listener"]["spec"]["triggers"][0]["interceptors"][0]["params"][0]["value"]
glr = r["eventlistener"]["gitlab-listener"]["spec"]["triggers"][1]["interceptors"][0]["params"][0]["value"]
glb = r["eventlistener"]["edp"]["spec"]["triggers"][0]["interceptors"][0]["params"][0]["value"]
glr = r["eventlistener"]["edp"]["spec"]["triggers"][1]["interceptors"][0]["params"][0]["value"]
gitserver = r["gitserver"]["gitlab"]["spec"]
assert "secretString" == glb["secretKey"] == glr["secretKey"]
assert "ci-gitlab" == glb["secretName"] == glr["secretName"]
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/gerrit/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ status:
apiVersion: apps/v1
kind: Deployment
metadata:
name: el-gerrit-listener
name: el-edp
status:
readyReplicas: 1
2 changes: 1 addition & 1 deletion tests/e2e/github/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ status:
apiVersion: apps/v1
kind: Deployment
metadata:
name: el-github-listener
name: el-edp
status:
readyReplicas: 1
2 changes: 1 addition & 1 deletion tests/e2e/gitlab/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ status:
apiVersion: apps/v1
kind: Deployment
metadata:
name: el-gitlab-listener
name: el-edp
status:
readyReplicas: 1

0 comments on commit 78b63cb

Please sign in to comment.