Skip to content

Commit

Permalink
fix: avoid hyphens
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Jun 24, 2024
1 parent db35d86 commit 50407ce
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 87 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ Note that this configuration is trivial and does not follow production recommand
| ingress.className | string | `"nginx"` | |
| ingress.enabled | bool | `true` | |
| ingress.tlsSecretName | string | `"myingress-cert"` | |
| init-cs.enabled | bool | `true` | |
| init-secrets.enabled | bool | `true` | |
| init-secrets.rbac.create | bool | `true` | |
| init-secrets.serviceAccount.create | bool | `true` | |
| init-secrets.serviceAccount.enabled | bool | `true` | |
| init-secrets.serviceAccount.name | string | `nil` | |
| init-sql.enabled | bool | `true` | |
| init-sql.env | object | `{}` | |
| initCs.enabled | bool | `true` | |
| initOs.enabled | bool | `true` | |
| initSecrets.enabled | bool | `true` | |
| initSecrets.rbac.create | bool | `true` | |
| initSecrets.serviceAccount.create | bool | `true` | |
| initSecrets.serviceAccount.enabled | bool | `true` | |
| initSecrets.serviceAccount.name | string | `nil` | |
| initSql.enabled | bool | `true` | |
| initSql.env | object | `{}` | |
| jaeger.agent.enabled | bool | `false` | |
| jaeger.allInOne.enabled | bool | `true` | |
| jaeger.collector.enabled | bool | `false` | |
Expand Down
8 changes: 4 additions & 4 deletions diracx/charts/cert-manager-issuer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cert-manager-issuer.name" -}}
{{- define "certManagerIssuer.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cert-manager-issuer.fullname" -}}
{{- define "certManagerIssuer.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
Expand All @@ -22,7 +22,7 @@ upgrades don't cause errors trying to create the already ran job.
Due to the helm delete not cleaning up these jobs, we add a random value to
reduce collision
*/}}
{{- define "cert-manager-issuer.jobname" -}}
{{- define "certManagerIssuer.jobname" -}}
{{- $name := printf "%s-issuer" .Release.Name | trunc 55 | trimSuffix "-" -}}
{{- printf "%s-%d" $name .Release.Revision | trunc 63 | trimSuffix "-" -}}
{{- end -}}
Expand All @@ -32,7 +32,7 @@ Returns the http01 solver's ingress class field. Takes the IngressClass as param
If the IngressClass is "none", the field is not set.
See: https://cert-manager.io/docs/configuration/acme/http01/#class
*/}}
{{- define "cert-manager-issuer.http01.ingress.class.field" -}}
{{- define "certManagerIssuer.http01.ingress.class.field" -}}
{{- $ingressClass := . | default "" -}}
{{- if ne "none" $ingressClass -}}
class: {{ $ingressClass }}
Expand Down
4 changes: 2 additions & 2 deletions diracx/charts/cert-manager-issuer/templates/_issuer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
# The ACME server URL
server: {{ .Values.acme.server | quote }}
# Email address used for ACME registration
email: {{ required "You must provide an email to associate with your TLS certificates. Please set certmanager-issuer.email" .Values.acme.email | quote }}
email: {{ required "You must provide an email to associate with your TLS certificates. Please set cert-manager-issuer.email" .Values.acme.email | quote }}
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: {{ .Release.Name }}-acme-key
Expand All @@ -20,7 +20,7 @@ spec:
- selector: {}
http01:
ingress:
{{ include "cert-manager-issuer.http01.ingress.class.field" $ingressClassName -}}
{{ include "certManagerIssuer.http01.ingress.class.field" $ingressClassName -}}
{{- end }}
---
{{- if index .Values "self-signed" "enabled" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "cert-manager-issuer.jobname" . }}
name: {{ template "certManagerIssuer.jobname" . }}
namespace: {{ $.Release.Namespace }}
spec:
ttlSecondsAfterFinished: {{ .Values.global.batchJobTTL }}
Expand Down
52 changes: 26 additions & 26 deletions diracx/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,102 +70,102 @@ Create the name of the service account to use
{{- end }}

{{/*
Return the fullname template for the init-cs job.
Return the fullname template for the initCs job.
*/}}
{{- define "init-cs.fullname" -}}
{{- define "initCs.fullname" -}}
{{- printf "%s-init-cs" .Release.Name -}}
{{- end -}}

{{/*
Create a default fully qualified job name for init-cs.
Create a default fully qualified job name for initCs.
Due to the job only being allowed to run once, we add the chart revision so helm
upgrades don't cause errors trying to create the already ran job.
Due to the helm delete not cleaning up these jobs, we add a random value to
reduce collisions.
*/}}
{{- define "init-cs.jobname" -}}
{{- $name := include "init-cs.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- define "initCs.jobname" -}}
{{- $name := include "initCs.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- $rand := randAlphaNum 3 | lower }}
{{- printf "%s-%d-%s" $name .Release.Revision $rand | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Return the fullname template for the init-secrets job.
Return the fullname template for the initSecrets job.
*/}}
{{- define "init-secrets.fullname" -}}
{{- define "initSecrets.fullname" -}}
{{- printf "%s-init-secrets" .Release.Name -}}
{{- end -}}
{{/*
Return the name template for shared-secrets job.
*/}}
{{- define "init-secrets.name" -}}
{{- $sharedSecretValues := index .Values "init-secrets" -}}
{{- define "initSecrets.name" -}}
{{- $sharedSecretValues := index .Values "initSecrets" -}}
{{- default "init-secrets" $sharedSecretValues.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified job name for init-secrets.
Create a default fully qualified job name for initSecrets.
Due to the job only being allowed to run once, we add the chart revision so helm
upgrades don't cause errors trying to create the already ran job.
Due to the helm delete not cleaning up these jobs, we add a random value to
reduce collisions.
*/}}
{{- define "init-secrets.jobname" -}}
{{- $name := include "init-secrets.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- define "initSecrets.jobname" -}}
{{- $name := include "initSecrets.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- $rand := randAlphaNum 3 | lower }}
{{- printf "%s-%d-%s" $name .Release.Revision $rand | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use for init-secrets job
Create the name of the service account to use for initSecrets job
*/}}
{{- define "init-secrets.serviceAccountName" -}}
{{- $initSecretsValues := index .Values "init-secrets" -}}
{{- define "initSecrets.serviceAccountName" -}}
{{- $initSecretsValues := index .Values "initSecrets" -}}
{{- if $initSecretsValues.serviceAccount.create -}}
{{ default (include "init-secrets.fullname" .) $initSecretsValues.serviceAccount.name }}
{{ default (include "initSecrets.fullname" .) $initSecretsValues.serviceAccount.name }}
{{- else -}}
{{ coalesce $initSecretsValues.serviceAccount.name .Values.global.serviceAccount.name "default" }}
{{- end -}}
{{- end -}}

{{/*
Return the fullname template for the init-sql job.
Return the fullname template for the initSql job.
*/}}
{{- define "init-sql.fullname" -}}
{{- define "initSql.fullname" -}}
{{- printf "%s-init-sql" .Release.Name -}}
{{- end -}}

{{/*
Create a default fully qualified job name for init-sql.
Create a default fully qualified job name for initSql.
Due to the job only being allowed to run once, we add the chart revision so helm
upgrades don't cause errors trying to create the already ran job.
Due to the helm delete not cleaning up these jobs, we add a random value to
reduce collisions.
*/}}
{{- define "init-sql.jobname" -}}
{{- $name := include "init-sql.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- define "initSql.jobname" -}}
{{- $name := include "initSql.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- $rand := randAlphaNum 3 | lower }}
{{- printf "%s-%d-%s" $name .Release.Revision $rand | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Return the fullname template for the init-os job.
Return the fullname template for the initOs job.
*/}}
{{- define "init-os.fullname" -}}
{{- define "initOs.fullname" -}}
{{- printf "%s-init-os" .Release.Name -}}
{{- end -}}
{{/*
Create a default fully qualified job name for init-os.
Create a default fully qualified job name for initOs.
Due to the job only being allowed to run once, we add the chart revision so helm
upgrades don't cause errors trying to create the already ran job.
Due to the helm delete not cleaning up these jobs, we add a random value to
reduce collisions.
*/}}
{{- define "init-os.jobname" -}}
{{- $name := include "init-os.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- define "initOs.jobname" -}}
{{- $name := include "initOs.fullname" . | trunc 55 | trimSuffix "-" -}}
{{- $rand := randAlphaNum 3 | lower }}
{{- printf "%s-%d-%s" $name .Release.Revision $rand | trunc 63 | trimSuffix "-" -}}
{{- end -}}
5 changes: 2 additions & 3 deletions diracx/templates/diracx/init-cs/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{{- $initCSValues := index .Values "init-cs" "enabled" -}}
{{- if $initCSValues -}}
{{- if .Values.initCs.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "init-cs.fullname" . }}
name: {{ template "initCs.fullname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install
Expand Down
11 changes: 5 additions & 6 deletions diracx/templates/diracx/init-cs/job.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $initCSValues := index .Values "init-cs" -}}
{{- if $initCSValues.enabled }}
{{- if .Values.initCs.enabled }}

{{/* Define common volume mounts for reusability */}}
{{- $commonVolumeMounts := list }}
Expand All @@ -23,7 +22,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "init-cs.jobname" . }}
name: {{ template "initCs.jobname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install
Expand All @@ -33,7 +32,7 @@ spec:
template:
metadata:
annotations:
{{- range $key, $value := $initCSValues.annotations }}
{{- range $key, $value := .Values.initCs.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
Expand All @@ -49,11 +48,11 @@ spec:
- name: scripts
mountPath: /scripts
resources:
{{- toYaml $initCSValues.resources | nindent 12 }}
{{- toYaml .Values.initCs.resources | nindent 12 }}
volumes:
- name: scripts
configMap:
name: {{ template "init-cs.fullname" . }}
name: {{ template "initCs.fullname" . }}
- name: cs-store-mount
persistentVolumeClaim:
claimName: pvc-cs-store
Expand Down
2 changes: 1 addition & 1 deletion diracx/templates/diracx/init-os/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "init-os.fullname" . }}
name: {{ template "initOs.fullname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,pre-upgrade
Expand Down
4 changes: 2 additions & 2 deletions diracx/templates/diracx/init-os/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "init-os.jobname" . }}
name: {{ template "initOs.jobname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,pre-upgrade
Expand Down Expand Up @@ -67,7 +67,7 @@ spec:
volumes:
- name: scripts
configMap:
name: {{ template "init-os.fullname" . }}
name: {{ template "initOs.fullname" . }}
{{- if and .Values.developer.enabled .Values.developer.mountedPythonModulesToInstall }}
- name: diracx-code-mount
persistentVolumeClaim:
Expand Down
5 changes: 2 additions & 3 deletions diracx/templates/diracx/init-secrets/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{{- $initSecretsValues := index .Values "init-secrets" "enabled" -}}
{{- if $initSecretsValues -}}
{{- if .Values.initSecrets.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "init-secrets.fullname" . }}
name: {{ template "initSecrets.fullname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
Expand Down
13 changes: 6 additions & 7 deletions diracx/templates/diracx/init-secrets/job.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{{- $initSecretsValues := index .Values "init-secrets" -}}
{{- if $initSecretsValues.enabled }}
{{- if .Values.initSecrets.enabled }}

apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "init-secrets.jobname" . }}
name: {{ template "initSecrets.jobname" . }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
Expand All @@ -15,12 +14,12 @@ spec:
template:
metadata:
annotations:
{{- range $key, $value := $initSecretsValues.annotations }}
{{- range $key, $value := .Values.initSecrets.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
restartPolicy: Never
serviceAccountName: {{ template "init-secrets.serviceAccountName" . }}
serviceAccountName: {{ template "initSecrets.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: ghcr.io/diracgrid/diracx/secret-generation:latest
Expand All @@ -30,9 +29,9 @@ spec:
- name: scripts
mountPath: /scripts
resources:
{{- toYaml $initSecretsValues.resources | nindent 12 }}
{{- toYaml .Values.initSecrets.resources | nindent 12 }}
volumes:
- name: scripts
configMap:
name: {{ template "init-secrets.fullname" . }}
name: {{ template "initSecrets.fullname" . }}
{{- end }}
Loading

0 comments on commit 50407ce

Please sign in to comment.