Skip to content

Commit

Permalink
refactor(charts): cleanup unneeded version checks (#1424)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt authored Jul 16, 2024
1 parent c2e9506 commit 76b18db
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,21 @@
{{- $fullName := include "txdc.fullname" . }}
{{- $controlLabels := include "txdc.controlplane.labels" . }}
{{- $controlEdcEndpoints := .Values.controlplane.endpoints }}
{{- $gitVersion := .Capabilities.KubeVersion.GitVersion }}
{{- $namespace := .Release.Namespace }}

{{- range .Values.controlplane.ingresses }}
{{- if and .enabled .endpoints }}
{{- $controlIngressName := printf "%s-controlplane-%s" $fullName .hostname }}
{{- $annotations := .annotations | default dict }}
---
{{- if semverCompare ">=1.19-0" $gitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $gitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $controlIngressName }}
namespace: {{ $namespace | default "default" | quote }}
labels:
{{- $controlLabels | nindent 4 }}
annotations:
{{- if and .className (not (semverCompare ">=1.18-0" $gitVersion)) }}
{{- if not (hasKey $annotations "kubernetes.io/ingress.class") }}
{{- $_ := set $annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if .certManager }}
{{- if .certManager.issuer }}
{{- $_ := set $annotations "cert-manager.io/issuer" .certManager.issuer}}
Expand All @@ -59,7 +47,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $gitVersion) }}
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .hostname }}
Expand All @@ -83,13 +71,10 @@ spec:
- path: {{ $mapping.path }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $gitVersion }}
service:
name: {{ $fullName }}-controlplane
port:
number: {{ $mapping.port }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,21 @@
{{- $fullName := include "txdc.fullname" . }}
{{- $dataLabels := include "txdc.dataplane.labels" . }}
{{- $dataEdcEndpoints := .Values.dataplane.endpoints }}
{{- $gitVersion := .Capabilities.KubeVersion.GitVersion }}
{{- $namespace := .Release.Namespace }}

{{- range .Values.dataplane.ingresses }}
{{- if and .enabled .endpoints }}
{{- $dataIngressName := printf "%s-dataplane-%s" $fullName .hostname }}
{{- $annotations := .annotations | default dict }}
---
{{- if semverCompare ">=1.19-0" $gitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $gitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $dataIngressName }}
namespace: {{ $namespace | default "default" | quote }}
labels:
{{- $dataLabels | nindent 4 }}
annotations:
{{- if and .className (not (semverCompare ">=1.18-0" $gitVersion)) }}
{{- if not (hasKey $annotations "kubernetes.io/ingress.class") }}
{{- $_ := set $annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if .certManager }}
{{- if .certManager.issuer }}
{{- $_ := set $annotations "cert-manager.io/issuer" .certManager.issuer}}
Expand All @@ -59,7 +47,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $gitVersion) }}
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .hostname }}
Expand All @@ -83,13 +71,10 @@ spec:
- path: {{ $mapping.path }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $gitVersion }}
service:
name: {{ $fullName }}-dataplane
port:
number: {{ $mapping.port }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
17 changes: 1 addition & 16 deletions charts/tractusx-connector-memory/templates/ingress-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,21 @@
{{- $fullName := include "txdc.fullname" . }}
{{- $controlLabels := include "txdc.runtime.labels" . }}
{{- $controlEdcEndpoints := .Values.runtime.endpoints }}
{{- $gitVersion := .Capabilities.KubeVersion.GitVersion }}
{{- $namespace := .Release.Namespace }}

{{- range .Values.runtime.ingresses }}
{{- if and .enabled .endpoints }}
{{- $controlIngressName := printf "%s-runtime-%s" $fullName .hostname }}
{{- $annotations := .annotations | default dict }}
---
{{- if semverCompare ">=1.19-0" $gitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $gitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $controlIngressName }}
namespace: {{ $namespace | default "default" | quote }}
labels:
{{- $controlLabels | nindent 4 }}
annotations:
{{- if and .className (not (semverCompare ">=1.18-0" $gitVersion)) }}
{{- if not (hasKey $annotations "kubernetes.io/ingress.class") }}
{{- $_ := set $annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if .certManager }}
{{- if .certManager.issuer }}
{{- $_ := set $annotations "cert-manager.io/issuer" .certManager.issuer}}
Expand All @@ -63,7 +51,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $gitVersion) }}
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .hostname }}
Expand All @@ -87,13 +75,10 @@ spec:
- path: {{ $mapping.path }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $gitVersion }}
service:
name: {{ $fullName }}-runtime
port:
number: {{ $mapping.port }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
17 changes: 1 addition & 16 deletions charts/tractusx-connector/templates/ingress-controlplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,21 @@
{{- $fullName := include "txdc.fullname" . }}
{{- $controlLabels := include "txdc.controlplane.labels" . }}
{{- $controlEdcEndpoints := .Values.controlplane.endpoints }}
{{- $gitVersion := .Capabilities.KubeVersion.GitVersion }}
{{- $namespace := .Release.Namespace }}

{{- range .Values.controlplane.ingresses }}
{{- if and .enabled .endpoints }}
{{- $controlIngressName := printf "%s-controlplane-%s" $fullName .hostname }}
{{- $annotations := .annotations | default dict }}
---
{{- if semverCompare ">=1.19-0" $gitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $gitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $controlIngressName }}
namespace: {{ $namespace | default "default" | quote }}
labels:
{{- $controlLabels | nindent 4 }}
annotations:
{{- if and .className (not (semverCompare ">=1.18-0" $gitVersion)) }}
{{- if not (hasKey $annotations "kubernetes.io/ingress.class") }}
{{- $_ := set $annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if .certManager }}
{{- if .certManager.issuer }}
{{- $_ := set $annotations "cert-manager.io/issuer" .certManager.issuer}}
Expand All @@ -63,7 +51,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $gitVersion) }}
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .hostname }}
Expand All @@ -87,13 +75,10 @@ spec:
- path: {{ $mapping.path }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $gitVersion }}
service:
name: {{ $fullName }}-controlplane
port:
number: {{ $mapping.port }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
17 changes: 1 addition & 16 deletions charts/tractusx-connector/templates/ingress-dataplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,21 @@
{{- $fullName := include "txdc.fullname" . }}
{{- $dataLabels := include "txdc.dataplane.labels" . }}
{{- $dataEdcEndpoints := .Values.dataplane.endpoints }}
{{- $gitVersion := .Capabilities.KubeVersion.GitVersion }}
{{- $namespace := .Release.Namespace }}

{{- range .Values.dataplane.ingresses }}
{{- if and .enabled .endpoints }}
{{- $dataIngressName := printf "%s-dataplane-%s" $fullName .hostname }}
{{- $annotations := .annotations | default dict }}
---
{{- if semverCompare ">=1.19-0" $gitVersion }}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $gitVersion }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $dataIngressName }}
namespace: {{ $namespace | default "default" | quote }}
labels:
{{- $dataLabels | nindent 4 }}
annotations:
{{- if and .className (not (semverCompare ">=1.18-0" $gitVersion)) }}
{{- if not (hasKey $annotations "kubernetes.io/ingress.class") }}
{{- $_ := set $annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- if .certManager }}
{{- if .certManager.issuer }}
{{- $_ := set $annotations "cert-manager.io/issuer" .certManager.issuer}}
Expand All @@ -63,7 +51,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .className (semverCompare ">=1.18-0" $gitVersion) }}
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .hostname }}
Expand All @@ -87,13 +75,10 @@ spec:
- path: {{ $mapping.path }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $gitVersion }}
service:
name: {{ $fullName }}-dataplane
port:
number: {{ $mapping.port }}
{{- else }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down

0 comments on commit 76b18db

Please sign in to comment.