Skip to content

Commit

Permalink
Change Ingress Api Version Logic
Browse files Browse the repository at this point in the history
Signed-off-by: sewieland <[email protected]>
  • Loading branch information
sewieland authored and Mirco Hacker committed Dec 10, 2021
1 parent 7673c62 commit 3c09f5c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/mailhog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
description: An e-mail testing tool for developers
name: mailhog
appVersion: v1.0.1
version: 5.0.1
version: 5.0.2
type: application
keywords:
- mailhog
Expand Down
11 changes: 0 additions & 11 deletions charts/mailhog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,3 @@ Create the name for the outgoing-smtp secret.
{{- template "mailhog.fullname" . -}}-outgoing-smtp
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "mailhog.ingressAPIVersion" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
{{- print "networking.k8s.io/v1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}
14 changes: 12 additions & 2 deletions charts/mailhog/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "mailhog.fullname" . -}}
apiVersion: {{ include "mailhog.ingressAPIVersion" . }}
{{- $apiV1 := false -}}
{{- $apiVersion := "extensions/v1beta1" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= v1.19.0-0" .Capabilities.KubeVersion.Version) -}}
{{- $apiVersion = "networking.k8s.io/v1" -}}
{{- $apiV1 = true -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- $apiVersion = "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- $apiVersion = "extensions/v1beta1" -}}
{{- end }}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand Down Expand Up @@ -37,7 +47,7 @@ spec:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
{{- if $apiV1 }}
pathType: {{ .pathType }}
backend:
service:
Expand Down

0 comments on commit 3c09f5c

Please sign in to comment.