From 2aff68e63375846a9942f8ff556d70b4a6e60f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= <91831478+lemeurherve@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:55:31 +0200 Subject: [PATCH] feat(mirrorbits): allow setting ingress `pathType` (#583) * 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 --- charts/mirrorbits/Chart.yaml | 2 +- charts/mirrorbits/templates/ingress.yaml | 2 +- .../mirrorbits/tests/custom_values_test.yaml | 21 +++++++++- charts/mirrorbits/tests/defaults_test.yaml | 38 +++++++++++++++++-- ...alues.yaml => secrets_default_values.yaml} | 0 charts/mirrorbits/values.yaml | 21 +++++----- 6 files changed, 67 insertions(+), 17 deletions(-) rename charts/mirrorbits/tests/{default_secrets_values.yaml => secrets_default_values.yaml} (100%) diff --git a/charts/mirrorbits/Chart.yaml b/charts/mirrorbits/Chart.yaml index 38a059a68..04f19ce15 100644 --- a/charts/mirrorbits/Chart.yaml +++ b/charts/mirrorbits/Chart.yaml @@ -5,4 +5,4 @@ maintainers: - email: me@olblak.com name: olblak name: mirrorbits -version: 0.55.0 +version: 0.56.0 diff --git a/charts/mirrorbits/templates/ingress.yaml b/charts/mirrorbits/templates/ingress.yaml index 4562d207f..97c7ef223 100644 --- a/charts/mirrorbits/templates/ingress.yaml +++ b/charts/mirrorbits/templates/ingress.yaml @@ -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 }} diff --git a/charts/mirrorbits/tests/custom_values_test.yaml b/charts/mirrorbits/tests/custom_values_test.yaml index 92e808c53..43e86d593 100644 --- a/charts/mirrorbits/tests/custom_values_test.yaml +++ b/charts/mirrorbits/tests/custom_values_test.yaml @@ -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: @@ -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" diff --git a/charts/mirrorbits/tests/defaults_test.yaml b/charts/mirrorbits/tests/defaults_test.yaml index efeb44860..3acf21050 100644 --- a/charts/mirrorbits/tests/defaults_test.yaml +++ b/charts/mirrorbits/tests/defaults_test.yaml @@ -1,7 +1,7 @@ suite: default tests values: - ../values.yaml - - default_secrets_values.yaml + - secrets_default_values.yaml templates: - deployment.files.yaml - deployment.yaml @@ -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: @@ -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: @@ -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: diff --git a/charts/mirrorbits/tests/default_secrets_values.yaml b/charts/mirrorbits/tests/secrets_default_values.yaml similarity index 100% rename from charts/mirrorbits/tests/default_secrets_values.yaml rename to charts/mirrorbits/tests/secrets_default_values.yaml diff --git a/charts/mirrorbits/values.yaml b/charts/mirrorbits/values.yaml index 575c4fd7b..60bbbdf96 100644 --- a/charts/mirrorbits/values.yaml +++ b/charts/mirrorbits/values.yaml @@ -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: