Skip to content
Snippets Groups Projects
Commit 39f5110d authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-4971 remove trunc 63 in helper' (#108) from OZG_4971 into master

parents 50e659e0 9478005a
Branches
Tags
No related merge requests found
{{/* vim: set filetype=mustache: */}} {{/* vim: set filetype=mustache: */}}
{{/* Truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec) */}}
{{/* Name */}}
{{- define "app.name" -}}
{{- default .Release.Name | toString | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/* Namespace */}} {{/* Namespace */}}
{{- define "app.namespace" -}} {{- define "app.namespace" -}}
{{- default .Release.Namespace | toString | trunc 63 | trimSuffix "-" -}} {{- if gt (len (.Release.Namespace)) 63 -}}
{{- fail (printf ".Release.Namespace %s ist zu lang (max. 63 Zeichen)" .Release.Namespace) -}}
{{- end -}} {{- end -}}
{{ printf "%s" .Release.Namespace }}
{{/* Version */}}
{{- define "app.version" -}}
{{- default .Chart.Version | toString | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/* Chart: Name + Version */}} {{/* Chart: Name + Version */}}
{{- define "app.chart" -}} {{- define "app.chart" -}}
{{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- if gt (len (printf "%s-%s" .Chart.Name .Chart.Version)) 63 -}}
{{- fail (printf ".Chart.Name-.Chart.Version %s-%s ist zu lang (max. 63 Zeichen)" .Chart.Name .Chart.Version) -}}
{{- end -}}
{{ printf "%s-%s" .Chart.Name .Chart.Version }}
{{- end -}} {{- end -}}
{{/* Managed-by -> On Helm, this value is always Helm */}} {{/* Managed-by -> On Helm, this value is always Helm */}}
{{- define "app.managedBy" -}} {{- define "app.managedBy" -}}
{{- default .Release.Service | toString | trunc 63 | trimSuffix "-" -}} {{- if gt (len (.Release.Service)) 63 -}}
{{- fail (printf ".Release.Service %s ist zu lang (max. 63 Zeichen)" .Release.Service) -}}
{{- end -}}
{{ printf "%s" .Release.Service }}
{{- end -}} {{- end -}}
{{/* Default Labels: Helm recommended best-practice labels https://helm.sh/docs/chart_best_practices/labels/ */}} {{/* Default Labels: Helm recommended best-practice labels https://helm.sh/docs/chart_best_practices/labels/ */}}
{{- define "app.defaultLabels" }} {{- define "app.defaultLabels" }}
app.kubernetes.io/instance: user-manager app.kubernetes.io/instance: user-manager
app.kubernetes.io/managed-by: {{ include "app.managedBy" . }} app.kubernetes.io/managed-by: {{ include "app.managedBy" . }}
app.kubernetes.io/name: {{ include "app.name" . }} app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/namespace: {{ include "app.namespace" . }} app.kubernetes.io/namespace: {{ include "app.namespace" . }}
app.kubernetes.io/part-of: ozgcloud app.kubernetes.io/part-of: ozgcloud
app.kubernetes.io/version: {{ include "app.version" . }} app.kubernetes.io/version: {{ .Chart.Version }}
helm.sh/chart: {{ include "app.chart" . }} helm.sh/chart: {{ include "app.chart" . }}
ozgcloud-mongodb-client: "true" ozgcloud-mongodb-client: "true"
{{- end -}} {{- end -}}
{{- define "app.matchLabels" }} {{- define "app.matchLabels" }}
app.kubernetes.io/name: {{ include "app.name" . }} app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/namespace: {{ include "app.namespace" . }} app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- end -}} {{- end -}}
...@@ -103,7 +101,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} ...@@ -103,7 +101,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- if (.Values.baseDomain) -}} {{- if (.Values.baseDomain) -}}
{{ .Values.baseDomain }} {{ .Values.baseDomain }}
{{- else -}} {{- else -}}
{{ printf "%s-%s.%s" (include "app.ozgcloudBezeichner" .) (include "app.name" .) (include "app.baseUrl" .) }} {{ printf "%s-%s.%s" (include "app.ozgcloudBezeichner" .) (.Release.Name) (include "app.baseUrl" .) }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
......
...@@ -35,12 +35,12 @@ spec: ...@@ -35,12 +35,12 @@ spec:
kind: Issuer kind: Issuer
duration: 8760h0m0s duration: 8760h0m0s
renewBefore: 720h0m0s renewBefore: 720h0m0s
commonName: {{ include "app.name" . }} commonName: {{ .Release.Name }}
dnsNames: dnsNames:
- "*.{{ include "app.name" . }}.{{ include "app.namespace" . }}.svc.cluster.local" - "*.{{ .Release.Name }}.{{ include "app.namespace" . }}.svc.cluster.local"
- "{{ include "app.name" . }}.{{ include "app.namespace" . }}.svc.cluster.local" - "{{ .Release.Name }}.{{ include "app.namespace" . }}.svc.cluster.local"
- "{{ include "app.name" . }}.{{ include "app.namespace" . }}.svc.cluster" - "{{ .Release.Name }}.{{ include "app.namespace" . }}.svc.cluster"
- "{{ include "app.name" . }}.{{ include "app.namespace" . }}.svc" - "{{ .Release.Name }}.{{ include "app.namespace" . }}.svc"
- "{{ include "app.name" . }}.{{ include "app.namespace" . }}" - "{{ .Release.Name }}.{{ include "app.namespace" . }}"
- "{{ include "app.name" . }}" - "{{ .Release.Name }}"
{{- end }} {{- end }}
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "app.name" . }} name: {{ .Release.Name }}
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
labels: labels:
{{- include "app.defaultLabels" . | indent 4 }} {{- include "app.defaultLabels" . | indent 4 }}
...@@ -57,7 +57,7 @@ spec: ...@@ -57,7 +57,7 @@ spec:
whenUnsatisfiable: ScheduleAnyway whenUnsatisfiable: ScheduleAnyway
labelSelector: labelSelector:
matchLabels: matchLabels:
app.kubernetes.io/name: {{ include "app.name" . }} app.kubernetes.io/name: {{ .Release.Name }}
containers: containers:
- env: - env:
- name: QUARKUS_MONGODB_CONNECTION_STRING - name: QUARKUS_MONGODB_CONNECTION_STRING
......
...@@ -36,7 +36,7 @@ metadata: ...@@ -36,7 +36,7 @@ metadata:
cert-manager.io/cluster-issuer: letsencrypt-prod cert-manager.io/cluster-issuer: letsencrypt-prod
{{- end }} {{- end }}
{{- end }} {{- end }}
name: {{ include "app.name" . }} name: {{ .Release.Name }}
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
spec: spec:
{{- if (.Values.ingress).className }} {{- if (.Values.ingress).className }}
...@@ -49,7 +49,7 @@ spec: ...@@ -49,7 +49,7 @@ spec:
service: service:
port: port:
number: 8080 number: 8080
name: {{ include "app.name" . }} name: {{ .Release.Name }}
path: '' path: ''
pathType: ImplementationSpecific pathType: ImplementationSpecific
host: {{ ( include "app.baseDomain" . ) }} host: {{ ( include "app.baseDomain" . ) }}
...@@ -60,6 +60,6 @@ spec: ...@@ -60,6 +60,6 @@ spec:
{{- if (.Values.ingress).tlsSecretName }} {{- if (.Values.ingress).tlsSecretName }}
secretName: {{ (.Values.ingress).tlsSecretName }} secretName: {{ (.Values.ingress).tlsSecretName }}
{{- else }} {{- else }}
secretName: {{ .Values.ozgcloud.bezeichner }}-{{ include "app.name" . }}-tls secretName: {{ .Values.ozgcloud.bezeichner }}-{{ .Release.Name }}-tls
{{- end }} {{- end }}
{{- end }} {{- end }}
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ include "app.name" . }} name: {{ .Release.Name }}
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
labels: labels:
{{- include "app.defaultLabels" . | indent 4 }} {{- include "app.defaultLabels" . | indent 4 }}
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
apiVersion: monitoring.coreos.com/v1 apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor kind: ServiceMonitor
metadata: metadata:
name: {{ include "app.name" . }} name: {{ .Release.Name }}
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
labels: labels:
{{- include "app.defaultLabels" . | indent 4 }} {{- include "app.defaultLabels" . | indent 4 }}
......
#
# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den
# Ministerpräsidenten des Landes Schleswig-Holstein
# Staatskanzlei
# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
#
# Lizenziert unter der EUPL, Version 1.2 oder - sobald
# diese von der Europäischen Kommission genehmigt wurden -
# Folgeversionen der EUPL ("Lizenz");
# Sie dürfen dieses Werk ausschließlich gemäß
# dieser Lizenz nutzen.
# Eine Kopie der Lizenz finden Sie hier:
#
# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
#
# Sofern nicht durch anwendbare Rechtsvorschriften
# gefordert oder in schriftlicher Form vereinbart, wird
# die unter der Lizenz verbreitete Software "so wie sie
# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
# ausdrücklich oder stillschweigend - verbreitet.
# Die sprachspezifischen Genehmigungen und Beschränkungen
# unter der Lizenz sind dem Lizenztext zu entnehmen.
#
suite: test deyploment less than 63 chars
release:
name: user-manager
namespace: sh-helm-test
templates:
- templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso.serverUrl: https://sso.company.local
baseUrl: test.company.local
tests:
- it: should fail on .Release.Namespace length longer than 63 characters
release:
namespace: test1234567890123123456789012345678901234567890123456789012345678901234567890123456789012345678904567890
asserts:
- failedTemplate:
errorMessage: .Release.Namespace test1234567890123123456789012345678901234567890123456789012345678901234567890123456789012345678904567890 ist zu lang (max. 63 Zeichen)
- it: should not fail on .Release.Namespace length less than 63 characters
asserts:
- notFailedTemplate: {}
- it: should fail on .Chart.Name-.Chart.Version length longer than 63 characters
chart:
version: 1.0-test1234567890123123456789012345678901234567890123456789012345678901234567890123456789012345678904567890
asserts:
- failedTemplate:
errorMessage: .Chart.Name-.Chart.Version user-manager-1.0-test1234567890123123456789012345678901234567890123456789012345678901234567890123456789012345678904567890 ist zu lang (max. 63 Zeichen)
- it: should not fail on .Chart.Name-.Chart.Version length less than 63 characters
asserts:
- notFailedTemplate: {}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment