diff --git a/library/common-test/tests/certificate/data_test.yaml b/library/common-test/tests/certificate/data_test.yaml index 06620e44..2768ed31 100644 --- a/library/common-test/tests/certificate/data_test.yaml +++ b/library/common-test/tests/certificate/data_test.yaml @@ -21,6 +21,7 @@ tests: enabled: true hosts: - host2 + - "*.host2.com" certificateIssuer: some-other-issuer certificateSecretTemplate: labels: @@ -72,6 +73,7 @@ tests: secretName: certificate-issuer-my-certificate2 dnsNames: - host2 + - "*.host2.com" issuerRef: name: some-other-issuer kind: ClusterIssuer diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index f3ef2c3a..30e28c46 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 16.2.3 +version: 16.2.4 diff --git a/library/common/templates/class/cert-manager/_certificate.tpl b/library/common/templates/class/cert-manager/_certificate.tpl index d4a41687..b07bda2b 100644 --- a/library/common/templates/class/cert-manager/_certificate.tpl +++ b/library/common/templates/class/cert-manager/_certificate.tpl @@ -33,7 +33,7 @@ spec: secretName: {{ $objectData.name }} dnsNames: {{- range $h := $objectData.hosts }} - - {{ tpl $h $rootCtx }} + - {{ (tpl $h $rootCtx) | quote }} {{- end }} privateKey: algorithm: ECDSA diff --git a/library/common/templates/spawner/_configmap.tpl b/library/common/templates/spawner/_configmap.tpl index 718a7368..1a84b043 100644 --- a/library/common/templates/spawner/_configmap.tpl +++ b/library/common/templates/spawner/_configmap.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $configmap) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "ConfigMap" + "key" "configmap")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_podDisruptionBudget.tpl b/library/common/templates/spawner/_podDisruptionBudget.tpl index 321c864c..20b10c99 100644 --- a/library/common/templates/spawner/_podDisruptionBudget.tpl +++ b/library/common/templates/spawner/_podDisruptionBudget.tpl @@ -7,36 +7,25 @@ {{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}} {{- range $name, $pdb := .Values.podDisruptionBudget -}} - {{- $enabled := false -}} - {{- if hasKey $pdb "enabled" -}} - {{- if not (kindIs "invalid" $pdb.enabled) -}} - {{- $enabled = $pdb.enabled -}} - {{- else -}} - {{- fail (printf "Pod Disruption Budget - Expected the defined key [enabled] in [podDisruptionBudget.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $pdb + "name" $name "caller" "Pod Disruption Budget" + "key" "podDistruptionBudget")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the poddisruptionbudget */}} {{- $objectData := (mustDeepCopy $pdb) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Pod Disruption Budget" + "key" "podDistruptionBudget")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} diff --git a/library/common/templates/spawner/_priorityClass.tpl b/library/common/templates/spawner/_priorityClass.tpl index 07ecb992..0f013244 100644 --- a/library/common/templates/spawner/_priorityClass.tpl +++ b/library/common/templates/spawner/_priorityClass.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the priorityclass */}} {{- $objectData := (mustDeepCopy $priorityclass) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Priority Class" + "key" "priorityClass")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* priorityclasss have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_secret.tpl b/library/common/templates/spawner/_secret.tpl index f6e68c23..480634f6 100644 --- a/library/common/templates/spawner/_secret.tpl +++ b/library/common/templates/spawner/_secret.tpl @@ -17,11 +17,15 @@ {{/* Create a copy of the secret */}} {{- $objectData := (mustDeepCopy $secret) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Secret" + "key" "secret")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_storageClass.tpl b/library/common/templates/spawner/_storageClass.tpl index 088045ba..894deea3 100644 --- a/library/common/templates/spawner/_storageClass.tpl +++ b/library/common/templates/spawner/_storageClass.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the storageclass */}} {{- $objectData := (mustDeepCopy $storageclass) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Storage Class" + "key" "storageClass")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_volumeSnapshot.tpl b/library/common/templates/spawner/_volumeSnapshot.tpl index f8fb545a..d12ce78d 100644 --- a/library/common/templates/spawner/_volumeSnapshot.tpl +++ b/library/common/templates/spawner/_volumeSnapshot.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the volumesnapshot */}} {{- $objectData := (mustDeepCopy $volumesnapshot) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Volume Snapshot" + "key" "volumeSnapshots")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* volumesnapshots have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_volumeSnapshotClass.tpl b/library/common/templates/spawner/_volumeSnapshotClass.tpl index 6b15825c..e628c03b 100644 --- a/library/common/templates/spawner/_volumeSnapshotClass.tpl +++ b/library/common/templates/spawner/_volumeSnapshotClass.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the volumesnapshotclass */}} {{- $objectData := (mustDeepCopy $volumesnapshotclass) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Volume Snapshot Class" + "key" "volumeSnapshotClass")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* volumesnapshotclasss have a max name length of 253 */}} diff --git a/library/common/templates/spawner/_webhook.tpl b/library/common/templates/spawner/_webhook.tpl index 90c0db10..106075c3 100644 --- a/library/common/templates/spawner/_webhook.tpl +++ b/library/common/templates/spawner/_webhook.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the mutatingWebhookConfiguration */}} {{- $objectData := (mustDeepCopy $mutatingWebhookConfiguration) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Webhook" + "key" "webhook")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} diff --git a/library/common/templates/spawner/cert-manager/_certificate.tpl b/library/common/templates/spawner/cert-manager/_certificate.tpl index 92389382..16657183 100644 --- a/library/common/templates/spawner/cert-manager/_certificate.tpl +++ b/library/common/templates/spawner/cert-manager/_certificate.tpl @@ -15,11 +15,15 @@ {{- if eq $enabled "true" -}} {{- $objectData := (mustDeepCopy $cert) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Cert Manager Certificate" + "key" "certificate")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* If a certificateSecretTemplate is defined, adjust name */}} diff --git a/library/common/templates/spawner/velero/_backupstoragelocation.tpl b/library/common/templates/spawner/velero/_backupstoragelocation.tpl index 86f45faa..c9d02a03 100644 --- a/library/common/templates/spawner/velero/_backupstoragelocation.tpl +++ b/library/common/templates/spawner/velero/_backupstoragelocation.tpl @@ -17,12 +17,15 @@ {{/* Create a copy of the backupstoragelocation */}} {{- $objectData := (mustDeepCopy $backupStorageLoc) -}} + {{- $objectName := $name -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Velero Backup Storage Location" + "key" "backupStorageLocation")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Set namespace to velero location or itself, just in case its used from within velero */}} diff --git a/library/common/templates/spawner/velero/_schedule.tpl b/library/common/templates/spawner/velero/_schedule.tpl index 4a01372b..922c2d90 100644 --- a/library/common/templates/spawner/velero/_schedule.tpl +++ b/library/common/templates/spawner/velero/_schedule.tpl @@ -17,11 +17,15 @@ {{/* Create a copy of the schedule */}} {{- $objectData := (mustDeepCopy $schedule) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Velero Schedule" + "key" "schedules")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Perform validations */}} {{/* schedules have a max name length of 253 */}} diff --git a/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl b/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl index 8ade18b2..1d664ce3 100644 --- a/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl +++ b/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl @@ -18,11 +18,15 @@ {{/* Create a copy of the volumesnapshotlocation */}} {{- $objectData := (mustDeepCopy $volSnapLoc) -}} - {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{- if hasKey $objectData "expandObjectName" -}} - {{- if not $objectData.expandObjectName -}} - {{- $objectName = $name -}} - {{- end -}} + {{- $objectName := $name -}} + + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Velero Volume Snapshot Location" + "key" "volumeSnapshotLocation")) -}} + + {{- if eq $expandName "true" -}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} {{- end -}} {{/* Set namespace to velero location or itself, just in case its used from within velero */}}