diff --git a/library/common-test/tests/certificate/validation_test.yaml b/library/common-test/tests/certificate/validation_test.yaml index 99cc8c7c..b8d9d475 100644 --- a/library/common-test/tests/certificate/validation_test.yaml +++ b/library/common-test/tests/certificate/validation_test.yaml @@ -5,15 +5,15 @@ release: name: test-release-name namespace: test-release-namespace tests: - - it: should fail with name longer than 63 characters + - it: should fail with name longer than 253 characters set: scaleCertificate: - my-certificate-super-long-name-that-is-longer-than-63-characters: + my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-long-long-long-long-long-name: enabled: true id: 1 asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-my-certificate-super-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-name-that-is-longer-than-253-characters-my-certificate-super-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with name starting with underscore set: @@ -23,7 +23,7 @@ tests: id: 1 asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-_my-cert] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-_my-cert] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with labels not a dict set: diff --git a/library/common-test/tests/configmap/validation_test.yaml b/library/common-test/tests/configmap/validation_test.yaml index 07190ff9..0026cf6a 100644 --- a/library/common-test/tests/configmap/validation_test.yaml +++ b/library/common-test/tests/configmap/validation_test.yaml @@ -5,16 +5,16 @@ release: name: test-release-name namespace: test-release-namespace tests: - - it: should fail with name longer than 63 characters + - it: should fail with name longer than 253 characters set: configmap: - my-configmap-super-long-name-that-is-longer-than-63-characters: + my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-long-long-long-long-long-long-long-name: enabled: true data: foo: bar asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-my-configmap-super-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-long-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with name starting with underscore set: @@ -25,7 +25,7 @@ tests: foo: bar asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-_my-configmap] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-_my-configmap] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with namespace longer than 63 characters set: diff --git a/library/common-test/tests/imagePullSecret/validation_test.yaml b/library/common-test/tests/imagePullSecret/validation_test.yaml index 4e963dcb..2a318afc 100644 --- a/library/common-test/tests/imagePullSecret/validation_test.yaml +++ b/library/common-test/tests/imagePullSecret/validation_test.yaml @@ -5,10 +5,10 @@ release: name: test-release-name namespace: test-release-namespace tests: - - it: should fail with name longer than 63 characters + - it: should fail with name longer than 253 characters set: imagePullSecret: - my-pull-secret-super-long-name-that-is-longer-than-63-characters: + my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-long-long-long-long-long-name: enabled: true data: &data registry: reg @@ -17,7 +17,7 @@ tests: email: mail asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-my-pull-secret-super-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-name-that-is-longer-than-253-characters-my-pull-secret-super-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with name starting with underscore set: @@ -27,7 +27,7 @@ tests: data: *data asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-_my-pull-secret] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-_my-pull-secret] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with labels not a dict set: diff --git a/library/common-test/tests/secret/validation_test.yaml b/library/common-test/tests/secret/validation_test.yaml index 1e4b3122..26140629 100644 --- a/library/common-test/tests/secret/validation_test.yaml +++ b/library/common-test/tests/secret/validation_test.yaml @@ -5,16 +5,16 @@ release: name: test-release-name namespace: test-release-namespace tests: - - it: should fail with name longer than 63 characters + - it: should fail with name longer than 253 characters set: secret: - my-secret-super-long-name-that-is-longer-than-63-characters: + my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-long-long-long-long-long-long-long-long-long-name: enabled: true data: foo: bar asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-my-secret-super-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-name-that-is-longer-than-253-characters-my-secret-super-long-long-long-long-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with name starting with underscore set: @@ -25,7 +25,7 @@ tests: foo: bar asserts: - failedTemplate: - errorMessage: Name [test-release-name-common-test-_my-secret] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters. + errorMessage: Name [test-release-name-common-test-_my-secret] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters. - it: should fail with labels not a dict set: diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 8fca2241..4577f418 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 14.0.7 +version: 14.0.8 diff --git a/library/common/templates/lib/chart/_names.tpl b/library/common/templates/lib/chart/_names.tpl index 9241b0ca..56e2efc2 100644 --- a/library/common/templates/lib/chart/_names.tpl +++ b/library/common/templates/lib/chart/_names.tpl @@ -33,9 +33,13 @@ {{- define "tc.v1.common.lib.chart.names.validation" -}} {{- $name := .name -}} + {{- $length := .length -}} + {{- if not $length -}} + {{- $length = 63 -}} + {{- end -}} - {{- if not (and (mustRegexMatch "^[a-z0-9](-?[a-z0-9]-?)+[a-z0-9]$" $name) (le (len $name) 63)) -}} - {{- fail (printf "Name [%s] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters." $name) -}} + {{- if not (and (mustRegexMatch "^[a-z0-9](-?[a-z0-9]-?)+[a-z0-9]$" $name) (le (len $name) $length)) -}} + {{- fail (printf "Name [%s] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most %v characters." $name $length) -}} {{- end -}} {{- end -}} diff --git a/library/common/templates/spawner/_configmap.tpl b/library/common/templates/spawner/_configmap.tpl index b55ac15c..8ed2eef6 100644 --- a/library/common/templates/spawner/_configmap.tpl +++ b/library/common/templates/spawner/_configmap.tpl @@ -41,8 +41,8 @@ {{- end -}} {{- end -}} - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}} {{- include "tc.v1.common.lib.configmap.validation" (dict "objectData" $objectData) -}} {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "ConfigMap") -}} diff --git a/library/common/templates/spawner/_imagePullSecret.tpl b/library/common/templates/spawner/_imagePullSecret.tpl index 0cce5a7a..30c4cc2d 100644 --- a/library/common/templates/spawner/_imagePullSecret.tpl +++ b/library/common/templates/spawner/_imagePullSecret.tpl @@ -15,8 +15,8 @@ {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}} {{- include "tc.v1.common.lib.imagePullSecret.validation" (dict "objectData" $objectData) -}} {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Image Pull Secret") -}} {{- $data := include "tc.v1.common.lib.imagePullSecret.createData" (dict "rootCtx" $ "objectData" $objectData) -}} diff --git a/library/common/templates/spawner/_portal.tpl b/library/common/templates/spawner/_portal.tpl index fd141b7c..e7e58e31 100644 --- a/library/common/templates/spawner/_portal.tpl +++ b/library/common/templates/spawner/_portal.tpl @@ -151,8 +151,8 @@ {{- $objectName := ( printf "tcportal-%s" $name ) -}} {{- $configMap := dict "enabled" true "name" $objectName "shortName" $objectName "data" $portalData -}} - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{/* Perform validations */}} {{/* Configmaps have a max name length of 253 */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}} {{- include "tc.v1.common.lib.configmap.validation" (dict "objectData" $configMap) -}} {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $configMap "caller" "ConfigMap") -}} diff --git a/library/common/templates/spawner/_scaleCertificate.tpl b/library/common/templates/spawner/_scaleCertificate.tpl index d69c703d..62859591 100644 --- a/library/common/templates/spawner/_scaleCertificate.tpl +++ b/library/common/templates/spawner/_scaleCertificate.tpl @@ -14,8 +14,8 @@ {{- $objectData := (mustDeepCopy $certificate) -}} {{- $objectName := (printf "%s-%s" $fullname $name) -}} - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}} {{- include "tc.v1.common.lib.scaleCertificate.validation" (dict "objectData" $objectData) -}} {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Certificate") -}} diff --git a/library/common/templates/spawner/_secret.tpl b/library/common/templates/spawner/_secret.tpl index 5b62d0c6..4d2f401e 100644 --- a/library/common/templates/spawner/_secret.tpl +++ b/library/common/templates/spawner/_secret.tpl @@ -40,8 +40,8 @@ {{- end -}} {{- end -}} - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{/* Perform validations */}} {{/* Secrets have a max name length of 253 */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}} {{- include "tc.v1.common.lib.secret.validation" (dict "objectData" $objectData) -}} {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Secret") -}}