diff --git a/packages/extra/seaweedfs/templates/seaweedfs-db.yaml b/packages/extra/seaweedfs/templates/seaweedfs-db.yaml index c86677c4d..261fcc93e 100644 --- a/packages/extra/seaweedfs/templates/seaweedfs-db.yaml +++ b/packages/extra/seaweedfs/templates/seaweedfs-db.yaml @@ -42,6 +42,6 @@ spec: resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.db.resourcesPreset .Values.db.resources $) | nindent 8 }} size: {{ .Values.db.size }} {{- with .Values.db.storageClass }} - storageClass: {{ . }} + storageClass: {{ . | quote }} {{- end }} {{- end }} diff --git a/packages/extra/seaweedfs/tests/db_storage_class_test.yaml b/packages/extra/seaweedfs/tests/db_storage_class_test.yaml new file mode 100644 index 000000000..da4f6cd2d --- /dev/null +++ b/packages/extra/seaweedfs/tests/db_storage_class_test.yaml @@ -0,0 +1,30 @@ +suite: seaweedfs metadata database storage class reaches its release as a string + +templates: + - templates/seaweedfs-db.yaml + +release: + name: seaweedfs + namespace: tenant-root + +tests: + # A StorageClass name may be all digits; handed on unquoted it reaches the + # database release as a number, and a line break in it would open new keys + # in that release's values. + - it: hands a numeric storage class name on as a string + set: + db: + storageClass: "123" + asserts: + - equal: + path: spec.values.db.storageClass + value: "123" + + - it: keeps a storage class with a line break inside its own field + set: + db: + storageClass: "local\n replicas: 9" + asserts: + - equal: + path: spec.values.db.storageClass + value: "local\n replicas: 9" diff --git a/packages/system/seaweedfs-db/templates/database.yaml b/packages/system/seaweedfs-db/templates/database.yaml index 807bd13af..136a3be83 100644 --- a/packages/system/seaweedfs-db/templates/database.yaml +++ b/packages/system/seaweedfs-db/templates/database.yaml @@ -11,7 +11,7 @@ spec: storage: size: {{ .Values.db.size }} {{- with .Values.db.storageClass }} - storageClass: {{ . }} + storageClass: {{ . | quote }} {{- end }} monitoring: diff --git a/packages/system/seaweedfs-db/tests/database_test.yaml b/packages/system/seaweedfs-db/tests/database_test.yaml index 3eff5a112..2e6244cf1 100644 --- a/packages/system/seaweedfs-db/tests/database_test.yaml +++ b/packages/system/seaweedfs-db/tests/database_test.yaml @@ -60,3 +60,17 @@ tests: - equal: path: spec.inheritedMetadata.labels["policy.cozystack.io/allow-to-apiserver"] value: "true" + + # A StorageClass name may be all digits; emitted unquoted it renders as a + # number, which the Cluster rejects. + - it: keeps a numeric storage class name a string + release: + name: seaweedfs-db + namespace: cozy-seaweedfs + set: + db: + storageClass: "123" + asserts: + - equal: + path: spec.storage.storageClass + value: "123"