Skip to content

Commit

Permalink
feat(mirrorbits): allow setting ingress pathType (jenkins-infra#583)
Browse files Browse the repository at this point in the history
* feat: allow setting the correct pathType for regexp ingress paths

* add default and custom tests for ingress pathType

* change filename to avoid confusion between defaults_test and default secrets values
  • Loading branch information
lemeurherve authored Aug 10, 2023
1 parent aa299c6 commit 2aff68e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 17 deletions.
2 changes: 1 addition & 1 deletion charts/mirrorbits/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ maintainers:
- email: [email protected]
name: olblak
name: mirrorbits
version: 0.55.0
version: 0.56.0
2 changes: 1 addition & 1 deletion charts/mirrorbits/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: Prefix
pathType: {{ .pathType | default "Prefix" }}
backend:
service:
name: {{ if .serviceNameSuffix }}{{ $fullName }}-{{ .serviceNameSuffix }}{{ else }}{{ $fullName }}{{ end }}
Expand Down
21 changes: 20 additions & 1 deletion charts/mirrorbits/tests/custom_values_test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
suite: Tests with custom values
values:
- default_secrets_values.yaml
- secrets_default_values.yaml
templates:
- deployment.yaml
- deployment.files.yaml
- ingress.yaml
- secret.yaml # Direct dependency of deployment.yaml
- service.files.yaml
tests:
Expand Down Expand Up @@ -65,3 +66,21 @@ tests:
- equal:
path: spec.template.spec.containers[*].imagePullPolicy
value: Always
- it: should create ingress with pathType set to the specified custom value by default
template: ingress.yaml
set:
ingress:
enabled: true
hosts:
- host: chart-example.local
paths:
- path: /
pathType: IfNotPresent
asserts:
- hasDocuments:
count: 1
- isKind:
of: Ingress
- equal:
path: spec.rules[0].http.paths[0].pathType
value: "IfNotPresent"
38 changes: 34 additions & 4 deletions charts/mirrorbits/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
suite: default tests
values:
- ../values.yaml
- default_secrets_values.yaml
- secrets_default_values.yaml
templates:
- deployment.files.yaml
- deployment.yaml
Expand All @@ -14,7 +14,24 @@ tests:
asserts:
- hasDocuments:
count: 0
- it: Should set the correct service selector labels
- it: should create ingress with pathType set to Prefix by default
template: ingress.yaml
set:
ingress:
enabled: true
hosts:
- host: chart-example.local
paths:
- path: /
asserts:
- hasDocuments:
count: 1
- isKind:
of: Ingress
- equal:
path: spec.rules[0].http.paths[0].pathType
value: "Prefix"
- it: should set the correct service selector labels
template: service.files.yaml
asserts:
- hasDocuments:
Expand All @@ -27,7 +44,20 @@ tests:
- equal:
path: spec.selector["app.kubernetes.io/instance"]
value: "RELEASE-NAME-files"
- it: should define the default "files" deployment
- it: Should set the correct deployment metadata labels
template: deployment.files.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/name"]
value: "mirrorbits-files"
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/instance"]
value: "RELEASE-NAME-files"
- it: should define the default "files" deployment with default imagePullPolicy and metadata labels
template: deployment.files.yaml
asserts:
- hasDocuments:
Expand All @@ -43,7 +73,7 @@ tests:
- equal:
path: "spec.template.spec.containers[*].imagePullPolicy"
value: IfNotPresent
- it: should define the default "mirrorbits" deployment
- it: should define the default "mirrorbits" deployment with default imagePullPolicy
template: deployment.yaml
asserts:
- hasDocuments:
Expand Down
21 changes: 11 additions & 10 deletions charts/mirrorbits/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ ingress:
className: ""
annotations: {}
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
serviceNameSuffix: files
- path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$
- host: fallback.chart-example.local
paths:
- path: /
serviceNameSuffix: files
hosts: []
# - host: chart-example.local
# paths:
# - path: /
# serviceNameSuffix: files
# - path: /.*[.](deb|hpi|war|rpm|msi|pkg|sha256|md5sum|zip|gz|pdf|json|svg|sh|jpeg|ico|png|html)$
# pathType: ImplementationSpecific
# - host: fallback.chart-example.local
# paths:
# - path: /
# serviceNameSuffix: files
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down

0 comments on commit 2aff68e

Please sign in to comment.