From 3001ffa368b262ddadcd5e32fa6240ef5fcecab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Ma=C5=84kowski?= Date: Wed, 30 Nov 2022 19:42:29 +0100 Subject: [PATCH] feat: add ingressClassName --- templates/ingress.yaml | 3 +++ test/linter/test.sh | 12 ++++++++++-- test/linter/values-lint.yaml | 2 +- test/unit/ingress.yaml | 22 ++++++++++++++++++++++ values.schema.json | 1 + values.yaml | 2 +- 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 13e9114..cc54af8 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -13,6 +13,9 @@ metadata: {{- . | toYaml | nindent 4 }} {{- end }} spec: +{{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className | quote }} +{{- end }} {{- if .Values.ingress.tls }} tls: - hosts: diff --git a/test/linter/test.sh b/test/linter/test.sh index bf132e3..b70da60 100755 --- a/test/linter/test.sh +++ b/test/linter/test.sh @@ -55,6 +55,16 @@ if [ $? -eq 0 ]; then exit 1 fi +helm lint . --strict --set 'ingress.className={1,2,3}' --set 'ingress.host=google' --set 'ingress.path=/' +if [ $? -eq 0 ]; then + exit 1 +fi + +helm lint . --strict --set 'ingress.className=nginx' --set 'ingress.host=google' --set 'ingress.path=/' +if [ $? -ne 0 ]; then + exit 1 +fi + helm lint . --strict --set 'ui.extraEnv=false' if [ $? -eq 0 ]; then exit 1 @@ -69,5 +79,3 @@ helm lint . --strict --set 'ui.extraEnv[0].name=qwe' --set 'ui.extraEnv[0].value if [ $? -ne 0 ]; then exit -1 fi - - diff --git a/test/linter/values-lint.yaml b/test/linter/values-lint.yaml index 41016dd..2aedbe9 100644 --- a/test/linter/values-lint.yaml +++ b/test/linter/values-lint.yaml @@ -40,6 +40,6 @@ reconcile: ingress: host: "cmak" path: "/" + className: "nginx" labels: my.label: "my.value" - diff --git a/test/unit/ingress.yaml b/test/unit/ingress.yaml index 3ce2736..f6de7b7 100644 --- a/test/unit/ingress.yaml +++ b/test/unit/ingress.yaml @@ -29,3 +29,25 @@ tests: - equal: path: spec.rules[0].http.paths[0].pathType value: Prefix + - it: should not render spec.ingressClassName by default + set: + ingress: + host: myhost + path: / + pathType: Prefix + asserts: + - isEmpty: + path: spec.ingressClassName + - it: should render spec.ingressClassName if specified + set: + ingress: + host: myhost + path: / + pathType: Prefix + className: nginx + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.ingressClassName + value: nginx diff --git a/values.schema.json b/values.schema.json index e5ffdf8..38cb0c1 100644 --- a/values.schema.json +++ b/values.schema.json @@ -187,6 +187,7 @@ "path": { "type": "string", "title": "ingress path" }, "pathType": { "type": "string", "title": "ingress pathType", "default": "ImplementationSpecific" }, "tls": { "$ref": "#/definitions/tls" }, + "className": { "type": ["null", "string"], "title": "ingress class name", "default": null }, "labels": { "type": "object", "title": "optional ingress labels", "default": {} }, "annotations": { "type": "object", "title": "optional ingress annotations", "default": {} } } diff --git a/values.yaml b/values.yaml index 2e289c1..cfc531a 100644 --- a/values.yaml +++ b/values.yaml @@ -139,6 +139,7 @@ ingress: null # # ingress # path: / # pathType: ImplementationSpecific + # className: nginx # # # Enable TLS configuration for the hostname defined at ingress.host # # secret name will be "${ingress.host.replace(".", "-")}" @@ -156,4 +157,3 @@ affinity: {} nodeSelector: {} tolerations: [] -