diff --git a/api/apps/v1alpha1/bucket/types.go b/api/apps/v1alpha1/bucket/types.go index 8a4f331d5..231b68780 100644 --- a/api/apps/v1alpha1/bucket/types.go +++ b/api/apps/v1alpha1/bucket/types.go @@ -19,6 +19,9 @@ type ConfigSpec struct { // Provisions bucket from the `-lock` BucketClass (with object lock enabled). // +kubebuilder:default:=false Locking bool `json:"locking"` + // With `locking`, keeps the default retention of the `-lock` BucketClass (COMPLIANCE, 365 days). Set to `false` to provision from the `-lock-noretention` BucketClass instead: Object Lock is enabled with no default retention, and retention is then set on the bucket or per object through the S3 API. Read at creation only. + // +kubebuilder:default:=true + LockingDefaultRetention bool `json:"lockingDefaultRetention"` // Selects a specific BucketClass by storage pool name. // +kubebuilder:default:="" StoragePool string `json:"storagePool,omitempty"` diff --git a/packages/apps/bucket/README.md b/packages/apps/bucket/README.md index 4db481810..65e2f6a89 100644 --- a/packages/apps/bucket/README.md +++ b/packages/apps/bucket/README.md @@ -4,12 +4,13 @@ ### Parameters -| Name | Description | Type | Value | -| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------- | -| `locking` | Provisions bucket from the `-lock` BucketClass (with object lock enabled). | `bool` | `false` | -| `storagePool` | Selects a specific BucketClass by storage pool name. | `string` | `""` | -| `ui` | Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `.`. Set to `false` to run the bucket without them. | `bool` | `true` | -| `publicRead` | Serves the bucket's objects to anyone without credentials at `//`. Anonymous callers can read objects but cannot list the bucket or write to it. | `bool` | `false` | -| `users` | Users configuration map. | `map[string]object` | `{}` | -| `users[name].readonly` | Whether the user has read-only access. | `bool` | `false` | +| Name | Description | Type | Value | +| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------- | +| `locking` | Provisions bucket from the `-lock` BucketClass (with object lock enabled). | `bool` | `false` | +| `lockingDefaultRetention` | With `locking`, keeps the default retention of the `-lock` BucketClass (COMPLIANCE, 365 days). Set to `false` to provision from the `-lock-noretention` BucketClass instead: Object Lock is enabled with no default retention, and retention is then set on the bucket or per object through the S3 API. Read at creation only. | `bool` | `true` | +| `storagePool` | Selects a specific BucketClass by storage pool name. | `string` | `""` | +| `ui` | Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `.`. Set to `false` to run the bucket without them. | `bool` | `true` | +| `publicRead` | Serves the bucket's objects to anyone without credentials at `//`. Anonymous callers can read objects but cannot list the bucket or write to it. | `bool` | `false` | +| `users` | Users configuration map. | `map[string]object` | `{}` | +| `users[name].readonly` | Whether the user has read-only access. | `bool` | `false` | diff --git a/packages/apps/bucket/templates/bucketclaim.yaml b/packages/apps/bucket/templates/bucketclaim.yaml index 8ce03d454..774aa0ee8 100644 --- a/packages/apps/bucket/templates/bucketclaim.yaml +++ b/packages/apps/bucket/templates/bucketclaim.yaml @@ -7,7 +7,7 @@ metadata: labels: app.kubernetes.io/instance: {{ .Release.Name }} spec: - bucketClassName: {{ $seaweedfs }}{{- if $pool }}-{{ $pool }}{{- end }}{{- if .Values.locking }}-lock{{- end }} + bucketClassName: {{ $seaweedfs }}{{- if $pool }}-{{ $pool }}{{- end }}{{- if .Values.locking }}-lock{{- if eq (toString .Values.lockingDefaultRetention) "false" }}-noretention{{- end }}{{- end }} protocols: - s3 {{- range $name, $user := .Values.users }} diff --git a/packages/apps/bucket/tests/bucketclaim_class_test.yaml b/packages/apps/bucket/tests/bucketclaim_class_test.yaml new file mode 100644 index 000000000..a11feeb48 --- /dev/null +++ b/packages/apps/bucket/tests/bucketclaim_class_test.yaml @@ -0,0 +1,80 @@ +suite: bucket BucketClass selection +templates: + - templates/bucketclaim.yaml + +release: + name: bucket-my-bucket + namespace: tenant-root + +set: + _namespace: + seaweedfs: tenant-root + +tests: + - it: provisions from the plain class by default + documentSelector: + path: kind + value: BucketClaim + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root + + - it: keeps the -lock class, with its default retention, when only locking is set + documentSelector: + path: kind + value: BucketClaim + set: + locking: true + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root-lock + + - it: provisions from -lock-noretention when the default retention is turned off + documentSelector: + path: kind + value: BucketClaim + set: + locking: true + lockingDefaultRetention: false + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root-lock-noretention + + - it: ignores lockingDefaultRetention without locking + documentSelector: + path: kind + value: BucketClaim + set: + lockingDefaultRetention: false + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root + + - it: keeps -lock when lockingDefaultRetention is absent from the values + documentSelector: + path: kind + value: BucketClaim + set: + locking: true + lockingDefaultRetention: null + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root-lock + + - it: puts the storage pool before the lock suffixes + documentSelector: + path: kind + value: BucketClaim + set: + storagePool: fast + locking: true + lockingDefaultRetention: false + asserts: + - equal: + path: spec.bucketClassName + value: tenant-root-fast-lock-noretention diff --git a/packages/apps/bucket/values.schema.json b/packages/apps/bucket/values.schema.json index 641822c51..b66da2015 100644 --- a/packages/apps/bucket/values.schema.json +++ b/packages/apps/bucket/values.schema.json @@ -7,6 +7,11 @@ "type": "boolean", "default": false }, + "lockingDefaultRetention": { + "description": "With `locking`, keeps the default retention of the `-lock` BucketClass (COMPLIANCE, 365 days). Set to `false` to provision from the `-lock-noretention` BucketClass instead: Object Lock is enabled with no default retention, and retention is then set on the bucket or per object through the S3 API. Read at creation only.", + "type": "boolean", + "default": true + }, "storagePool": { "description": "Selects a specific BucketClass by storage pool name.", "type": "string", diff --git a/packages/apps/bucket/values.yaml b/packages/apps/bucket/values.yaml index a5d87b9b3..32448d8a6 100644 --- a/packages/apps/bucket/values.yaml +++ b/packages/apps/bucket/values.yaml @@ -1,6 +1,9 @@ ## @param {bool} locking=false - Provisions bucket from the `-lock` BucketClass (with object lock enabled). locking: false +## @param {bool} lockingDefaultRetention=true - With `locking`, keeps the default retention of the `-lock` BucketClass (COMPLIANCE, 365 days). Set to `false` to provision from the `-lock-noretention` BucketClass instead: Object Lock is enabled with no default retention, and retention is then set on the bucket or per object through the S3 API. Read at creation only. +lockingDefaultRetention: true + ## @param {string} [storagePool] - Selects a specific BucketClass by storage pool name. ## @x-cozystack-options {source: storagepool} storagePool: "" diff --git a/packages/extra/seaweedfs/templates/client/cosi-bucket-class.yaml b/packages/extra/seaweedfs/templates/client/cosi-bucket-class.yaml index 0b262f47d..8037bc9df 100644 --- a/packages/extra/seaweedfs/templates/client/cosi-bucket-class.yaml +++ b/packages/extra/seaweedfs/templates/client/cosi-bucket-class.yaml @@ -18,6 +18,15 @@ parameters: objectLockRetentionMode: "COMPLIANCE" objectLockRetentionDays: "365" --- +kind: BucketClass +apiVersion: objectstorage.k8s.io/v1alpha1 +metadata: + name: {{ .Release.Namespace }}-lock-noretention +driverName: {{ .Release.Namespace }}.seaweedfs.objectstorage.k8s.io +deletionPolicy: Retain +parameters: + objectLockEnabled: "true" +--- kind: BucketAccessClass apiVersion: objectstorage.k8s.io/v1alpha1 metadata: diff --git a/packages/extra/seaweedfs/templates/seaweedfs.yaml b/packages/extra/seaweedfs/templates/seaweedfs.yaml index b77cf44c4..6c98591df 100644 --- a/packages/extra/seaweedfs/templates/seaweedfs.yaml +++ b/packages/extra/seaweedfs/templates/seaweedfs.yaml @@ -76,6 +76,36 @@ {{- end }} {{- end }} +{{- /* -lock-noretention is not a reserved suffix: releases with pools named + that way predate the class, and refusing the name would block their + upgrade. Only an actual clash between rendered class names fails, + across both pool paths and against the base classes. */ -}} +{{- if gt (len $allPools) 0 }} +{{- $classOwners := dict }} +{{- range $suffix := list "" "-lock" "-lock-noretention" }} +{{- $_ := set $classOwners (printf "BucketClass %s%s" $.Release.Namespace $suffix) "the base classes" }} +{{- end }} +{{- range $suffix := list "" "-readonly" "-public" }} +{{- $_ := set $classOwners (printf "BucketAccessClass %s%s" $.Release.Namespace $suffix) "the base classes" }} +{{- end }} +{{- range $poolName, $_ := $allPools }} +{{- $owner := printf "storage pool '%s'" $poolName }} +{{- $names := list }} +{{- range $suffix := list "" "-lock" "-lock-noretention" }} +{{- $names = append $names (printf "BucketClass %s-%s%s" $.Release.Namespace $poolName $suffix) }} +{{- end }} +{{- range $suffix := list "" "-readonly" "-public" }} +{{- $names = append $names (printf "BucketAccessClass %s-%s%s" $.Release.Namespace $poolName $suffix) }} +{{- end }} +{{- range $name := $names }} +{{- if hasKey $classOwners $name }} +{{- fail (printf "%s renders %s, also rendered by %s; rename the pool." $owner $name (get $classOwners $name)) }} +{{- end }} +{{- $_ := set $classOwners $name $owner }} +{{- end }} +{{- end }} +{{- end }} + {{- $detectedTopology := "Unknown" }} {{- $configMap := lookup "v1" "ConfigMap" .Release.Namespace (printf "%s-deployed-topology" .Release.Name) }} {{- if $configMap }} diff --git a/packages/extra/seaweedfs/templates/storage-pool-bucket-classes.yaml b/packages/extra/seaweedfs/templates/storage-pool-bucket-classes.yaml index faa99f137..5ad3b2ab2 100644 --- a/packages/extra/seaweedfs/templates/storage-pool-bucket-classes.yaml +++ b/packages/extra/seaweedfs/templates/storage-pool-bucket-classes.yaml @@ -34,6 +34,16 @@ parameters: objectLockRetentionMode: "COMPLIANCE" objectLockRetentionDays: "365" --- +kind: BucketClass +apiVersion: objectstorage.k8s.io/v1alpha1 +metadata: + name: {{ $.Release.Namespace }}-{{ $poolName }}-lock-noretention +driverName: {{ $.Release.Namespace }}.seaweedfs.objectstorage.k8s.io +deletionPolicy: Retain +parameters: + disk: {{ $diskType }} + objectLockEnabled: "true" +--- kind: BucketAccessClass apiVersion: objectstorage.k8s.io/v1alpha1 metadata: diff --git a/packages/extra/seaweedfs/tests/lock_noretention_bucket_class_test.yaml b/packages/extra/seaweedfs/tests/lock_noretention_bucket_class_test.yaml new file mode 100644 index 000000000..1348a910a --- /dev/null +++ b/packages/extra/seaweedfs/tests/lock_noretention_bucket_class_test.yaml @@ -0,0 +1,201 @@ +suite: seaweedfs lock BucketClass without default retention + +# The -lock-noretention class enables Object Lock and sets no default +# retention, so the retention is chosen afterwards through the S3 API. It +# keeps deletionPolicy Retain like -lock: the driver deletes a bucket through +# the filer without checking retention, so Delete would destroy objects still +# under COMPLIANCE. + +templates: + - templates/client/cosi-bucket-class.yaml + - templates/storage-pool-bucket-classes.yaml + - templates/seaweedfs.yaml + +release: + name: seaweedfs + namespace: tenant-root + +tests: + - it: renders the class for a Client topology + template: templates/client/cosi-bucket-class.yaml + set: + topology: Client + filer: + grpcHost: seaweedfs-filer + grpcPort: 18888 + documentSelector: + path: metadata.name + value: tenant-root-lock-noretention + asserts: + - isKind: + of: BucketClass + - equal: + path: driverName + value: tenant-root.seaweedfs.objectstorage.k8s.io + - equal: + path: deletionPolicy + value: Retain + - equal: + path: parameters + value: + objectLockEnabled: "true" + + - it: renders the class for each storage pool, with its disk type + template: templates/storage-pool-bucket-classes.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + fast: + diskType: ssd + documentSelector: + path: metadata.name + value: tenant-root-fast-lock-noretention + asserts: + - isKind: + of: BucketClass + - equal: + path: deletionPolicy + value: Retain + - equal: + path: parameters + value: + disk: ssd + objectLockEnabled: "true" + + - it: accepts a storage pool whose name ends with -lock-noretention + template: templates/seaweedfs.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + archive-lock-noretention: + diskType: ssd + asserts: + - notFailedTemplate: {} + + - it: refuses a pool whose base class is another pool's -lock-noretention class + template: templates/seaweedfs.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + archive: + diskType: ssd + archive-lock-noretention: + diskType: hdd + asserts: + - failedTemplate: + errorMessage: "storage pool 'archive-lock-noretention' renders BucketClass tenant-root-archive-lock-noretention, also rendered by storage pool 'archive'; rename the pool." + + - it: refuses the same clash between pools of different zones + template: templates/seaweedfs.yaml + set: + topology: MultiZone + replicationFactor: 1 + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + zones: + a: + pools: + archive: + diskType: ssd + b: + pools: + archive-lock-noretention: + diskType: hdd + asserts: + - failedTemplate: + errorMessage: "storage pool 'archive-lock-noretention' renders BucketClass tenant-root-archive-lock-noretention, also rendered by storage pool 'archive'; rename the pool." + + - it: refuses a storage pool named exactly lock-noretention + template: templates/seaweedfs.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + lock-noretention: + diskType: ssd + asserts: + - failedTemplate: + errorMessage: "storage pool 'lock-noretention' renders BucketClass tenant-root-lock-noretention, also rendered by the base classes; rename the pool." + + - it: refuses a storage pool named exactly lock + template: templates/seaweedfs.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + lock: + diskType: ssd + asserts: + - failedTemplate: + errorMessage: "storage pool 'lock' renders BucketClass tenant-root-lock, also rendered by the base classes; rename the pool." + + - it: refuses a storage pool named exactly readonly + template: templates/seaweedfs.yaml + set: + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + pools: + readonly: + diskType: ssd + asserts: + - failedTemplate: + errorMessage: "storage pool 'readonly' renders BucketAccessClass tenant-root-readonly, also rendered by the base classes; rename the pool." + + - it: refuses a zone storage pool named exactly lock-noretention + template: templates/seaweedfs.yaml + set: + topology: MultiZone + replicationFactor: 1 + _namespace: + host: example.org + ingress: tenant-root + _cluster: + issuer-name: letsencrypt-prod + solver: http01 + volume: + zones: + a: + pools: + lock-noretention: + diskType: ssd + asserts: + - failedTemplate: + errorMessage: "storage pool 'lock-noretention' renders BucketClass tenant-root-lock-noretention, also rendered by the base classes; rename the pool." diff --git a/packages/system/bucket-rd/cozyrds/bucket.yaml b/packages/system/bucket-rd/cozyrds/bucket.yaml index 0f05f4dfe..aacdbf670 100644 --- a/packages/system/bucket-rd/cozyrds/bucket.yaml +++ b/packages/system/bucket-rd/cozyrds/bucket.yaml @@ -8,7 +8,7 @@ spec: plural: buckets singular: bucket openAPISchema: |- - {"title":"Chart Values","type":"object","properties":{"locking":{"description":"Provisions bucket from the `-lock` BucketClass (with object lock enabled).","type":"boolean","default":false},"storagePool":{"description":"Selects a specific BucketClass by storage pool name.","type":"string","default":"","x-cozystack-options":{"source":"storagepool"}},"ui":{"description":"Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `.`. Set to `false` to run the bucket without them.","type":"boolean","default":true},"publicRead":{"description":"Serves the bucket's objects to anyone without credentials at `//`. Anonymous callers can read objects but cannot list the bucket or write to it.","type":"boolean","default":false},"users":{"description":"Users configuration map.","type":"object","default":{},"additionalProperties":{"type":"object","properties":{"readonly":{"description":"Whether the user has read-only access.","type":"boolean"}}}}}} + {"title":"Chart Values","type":"object","properties":{"locking":{"description":"Provisions bucket from the `-lock` BucketClass (with object lock enabled).","type":"boolean","default":false},"lockingDefaultRetention":{"description":"With `locking`, keeps the default retention of the `-lock` BucketClass (COMPLIANCE, 365 days). Set to `false` to provision from the `-lock-noretention` BucketClass instead: Object Lock is enabled with no default retention, and retention is then set on the bucket or per object through the S3 API. Read at creation only.","type":"boolean","default":true},"storagePool":{"description":"Selects a specific BucketClass by storage pool name.","type":"string","default":"","x-cozystack-options":{"source":"storagepool"}},"ui":{"description":"Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `.`. Set to `false` to run the bucket without them.","type":"boolean","default":true},"publicRead":{"description":"Serves the bucket's objects to anyone without credentials at `//`. Anonymous callers can read objects but cannot list the bucket or write to it.","type":"boolean","default":false},"users":{"description":"Users configuration map.","type":"object","default":{},"additionalProperties":{"type":"object","properties":{"readonly":{"description":"Whether the user has read-only access.","type":"boolean"}}}}}} release: prefix: bucket- labels: @@ -26,7 +26,7 @@ spec: tags: - storage icon: PHN2ZyB3aWR0aD0iMTQ0IiBoZWlnaHQ9IjE0NCIgdmlld0JveD0iMCAwIDE0NCAxNDQ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9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRjBFRSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNFQzg4N0QiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K - keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ["metadata"], ["metadata", "name"], ["spec", "locking"], ["spec", "storagePool"], ["spec", "ui"], ["spec", "publicRead"], ["spec", "users"]] + keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ["metadata"], ["metadata", "name"], ["spec", "locking"], ["spec", "lockingDefaultRetention"], ["spec", "storagePool"], ["spec", "ui"], ["spec", "publicRead"], ["spec", "users"]] secrets: exclude: [] include: diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml index 11d7fb779..77081bee8 100644 --- a/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml +++ b/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml @@ -22,6 +22,15 @@ parameters: objectLockRetentionMode: "COMPLIANCE" objectLockRetentionDays: "365" --- +kind: BucketClass +apiVersion: objectstorage.k8s.io/v1alpha1 +metadata: + name: {{ .Values.cosi.bucketClassName }}-lock-noretention +driverName: {{ .Values.cosi.driverName }} +deletionPolicy: Retain +parameters: + objectLockEnabled: "true" +--- kind: BucketAccessClass apiVersion: objectstorage.k8s.io/v1alpha1 metadata: diff --git a/packages/system/seaweedfs/patches/cosi-bucket-class-lock-readonly.patch b/packages/system/seaweedfs/patches/cosi-bucket-class-lock-readonly.patch index 84ca4fcf2..9f6b96eab 100644 --- a/packages/system/seaweedfs/patches/cosi-bucket-class-lock-readonly.patch +++ b/packages/system/seaweedfs/patches/cosi-bucket-class-lock-readonly.patch @@ -2,7 +2,7 @@ diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-buck index 4d19cc128..11d7fb779 100644 --- a/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml +++ b/packages/system/seaweedfs/charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml -@@ -11,10 +11,41 @@ +@@ -11,10 +11,50 @@ {{- toYaml . | nindent 2 }} {{- end }} --- @@ -16,6 +16,15 @@ index 4d19cc128..11d7fb779 100644 + objectLockEnabled: "true" + objectLockRetentionMode: "COMPLIANCE" + objectLockRetentionDays: "365" ++--- ++kind: BucketClass ++apiVersion: objectstorage.k8s.io/v1alpha1 ++metadata: ++ name: {{ .Values.cosi.bucketClassName }}-lock-noretention ++driverName: {{ .Values.cosi.driverName }} ++deletionPolicy: Retain ++parameters: ++ objectLockEnabled: "true" +--- kind: BucketAccessClass apiVersion: objectstorage.k8s.io/v1alpha1 diff --git a/packages/system/seaweedfs/tests/cosi_lock_noretention_bucket_class_test.yaml b/packages/system/seaweedfs/tests/cosi_lock_noretention_bucket_class_test.yaml new file mode 100644 index 000000000..9014a69eb --- /dev/null +++ b/packages/system/seaweedfs/tests/cosi_lock_noretention_bucket_class_test.yaml @@ -0,0 +1,49 @@ +suite: seaweedfs COSI lock BucketClass without default retention + +# patches/cosi-bucket-class-lock-readonly.patch adds the -lock-noretention +# class next to -lock: Object Lock enabled, no default retention, and Retain, +# because the driver deletes a bucket through the filer without checking +# retention. Upstream renders neither class, so this fails on unpatched code. + +templates: + - charts/seaweedfs/templates/cosi/cosi-bucket-class.yaml + +release: + name: seaweedfs-system + namespace: tenant-root + +tests: + - it: renders the class with Object Lock enabled and no default retention + set: + seaweedfs.cosi.bucketClassName: tenant-root + seaweedfs.cosi.driverName: tenant-root.seaweedfs.objectstorage.k8s.io + documentSelector: + path: metadata.name + value: tenant-root-lock-noretention + asserts: + - isKind: + of: BucketClass + - equal: + path: driverName + value: tenant-root.seaweedfs.objectstorage.k8s.io + - equal: + path: deletionPolicy + value: Retain + - equal: + path: parameters + value: + objectLockEnabled: "true" + + - it: leaves the -lock class and its default retention unchanged + set: + seaweedfs.cosi.bucketClassName: tenant-root + documentSelector: + path: metadata.name + value: tenant-root-lock + asserts: + - equal: + path: parameters + value: + objectLockEnabled: "true" + objectLockRetentionMode: COMPLIANCE + objectLockRetentionDays: "365"