diff --git a/README.md b/README.md index 510a3ba..9f8712a 100644 --- a/README.md +++ b/README.md @@ -905,15 +905,16 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo ### Ingress -| Name | Description | Value | -| ------------------------ | -------------------- | ----------------- | -| `ingress.enabled` | Enable ingress | `false` | -| `ingress.className` | Ingress class name | `nil` | -| `ingress.pathType` | Ingress Path Type | `Prefix` | -| `ingress.annotations` | Ingress annotations | `{}` | -| `ingress.hosts[0].host` | Default Ingress host | `git.example.com` | -| `ingress.hosts[0].paths` | Default Ingress path | `[]` | -| `ingress.tls` | Ingress tls settings | `[]` | +| Name | Description | Value | +| -------------------------- | -------------------- | ----------------- | +| `ingress.enabled` | Enable ingress | `false` | +| `ingress.className` | Ingress class name | `""` | +| `ingress.ingressClassName` | Ingress class name | `""` | +| `ingress.pathType` | Ingress Path Type | `Prefix` | +| `ingress.annotations` | Ingress annotations | `{}` | +| `ingress.hosts[0].host` | Default Ingress host | `git.example.com` | +| `ingress.hosts[0].paths` | Default Ingress path | `[]` | +| `ingress.tls` | Ingress tls settings | `[]` | ### deployment diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index c4eeec1..0790895 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -403,4 +403,16 @@ https {{- toYaml .Values.ingress.annotations | nindent 4 }} {{- end }} {{- end }} +{{- end -}} + +{{- /* Deprecations */ -}} +{{- /* 10.4.0 (2024-07) */ -}} +{{- define "deprecations" -}} + {{- if ne .Values.ingress.className "" }} + {{- printf "# WARNING: 'ingress.className' is deprecated and will be removed in a future release. Use 'ingress.ingressClassName' instead.\n" -}} + {{- end -}} + + {{- if and (ne .Values.ingress.className "" ) (ne .Values.ingress.ingressClassName "") -}} + {{- fail "ingress.ingressClassName and ingress.className cannot be defined at the same time. Please only choose one." -}} + {{- end -}} {{- end -}} \ No newline at end of file diff --git a/templates/gitea/ingress.yaml b/templates/gitea/ingress.yaml index aa067b6..4429b83 100644 --- a/templates/gitea/ingress.yaml +++ b/templates/gitea/ingress.yaml @@ -1,3 +1,4 @@ +{{- include "deprecations" . -}} {{- if .Values.ingress.enabled -}} {{- $fullName := include "gitea.fullname" . -}} {{- $httpPort := .Values.service.http.port -}} @@ -10,8 +11,10 @@ metadata: {{- include "gitea.labels" . | nindent 4 }} {{- template "ingress.annotations" . }} spec: -{{- if .Values.ingress.className }} +{{- if ne .Values.ingress.className "" }} ingressClassName: {{ tpl .Values.ingress.className . }} +{{- else }} + ingressClassName: {{ tpl .Values.ingress.ingressClassName . }} {{- end }} {{- if .Values.ingress.tls }} tls: diff --git a/unittests/ingress/basic.yaml b/unittests/ingress/basic.yaml index 733e557..8cf3d87 100644 --- a/unittests/ingress/basic.yaml +++ b/unittests/ingress/basic.yaml @@ -53,7 +53,7 @@ tests: - it: Ingress Class using TPL set: global.ingress.className: "ingress-class" - ingress.className: "{{ .Values.global.ingress.className }}" + ingress.ingressClassName: "{{ .Values.global.ingress.className }}" ingress.enabled: true ingress.hosts[0].host: "some-host" ingress.tls: diff --git a/unittests/ingress/deprecations.yaml b/unittests/ingress/deprecations.yaml new file mode 100644 index 0000000..512ff8e --- /dev/null +++ b/unittests/ingress/deprecations.yaml @@ -0,0 +1,43 @@ +suite: Test ingress.yaml +templates: + - templates/gitea/ingress.yaml +tests: + - it: should fail when both ingress.className and ingress.ingressClassName are defined + set: + ingress.enabled: true + ingress.className: "ingress-class" + ingress.ingressClassName: "ingress-class" + asserts: + - failedTemplate: + errorMessage: "ingress.ingressClassName and ingress.className cannot be defined at the same time. Please only choose one." + + - it: should succeed when only ingress.className is defined + set: + ingress.enabled: true + ingress.ingressClassName: "ingress-class" + asserts: + - hasDocuments: + count: 1 + + - it: should succeed when only ingress.ingressClassName is defined + set: + ingress.enabled: true + ingress.ingressClassName: "ingress-class" + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.ingressClassName + value: ingress-class + + - it: should succeed when neither ingress.className nor ingress.ingressClassName are defined + set: + ingress.enabled: true + ingress.className: "ingress-class" + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.ingressClassName + value: ingress-class + diff --git a/values.yaml b/values.yaml index 3878e08..c315fd4 100644 --- a/values.yaml +++ b/values.yaml @@ -151,6 +151,7 @@ service: ## @section Ingress ## @param ingress.enabled Enable ingress ## @param ingress.className Ingress class name +## @param ingress.ingressClassName Ingress class name ## @param ingress.pathType Ingress Path Type ## @param ingress.annotations Ingress annotations ## @param ingress.hosts[0].host Default Ingress host @@ -158,13 +159,12 @@ service: ## @param ingress.tls Ingress tls settings ingress: enabled: false - # className: nginx - className: + # DEPRECATED: Use `ingress.ingressClassName` instead. + className: "" + ingressClassName: "" pathType: Prefix - annotations: - {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" + annotations: {} + # kubernetes.io/tls-acme: "true" hosts: - host: git.example.com paths: [] @@ -172,9 +172,6 @@ ingress: # - secretName: chart-example-tls # hosts: # - git.example.com - # Mostly for argocd or any other CI that uses `helm template | kubectl apply` or similar - # If helm doesn't correctly detect your ingress API version you can set it here. - # apiVersion: networking.k8s.io/v1 ## @section deployment #