diff --git a/api/v1alpha1/dataset_types.go b/api/v1alpha1/dataset_types.go
index 91524bc89e1..efb95952e2d 100644
--- a/api/v1alpha1/dataset_types.go
+++ b/api/v1alpha1/dataset_types.go
@@ -123,15 +123,19 @@ type DataRestoreLocation struct {
}
// DatasetSpec defines the desired state of Dataset
+// +kubebuilder:validation:XValidation:rule="self.allowEmptyMounts == true || (has(self.mounts) && size(self.mounts) >= 1)",message="Mounts must have at least one item unless AllowEmptyMounts is true"
type DatasetSpec struct {
// Mount Points to be mounted on cache runtime.
// This field can be empty because some runtimes don't need to mount external storage (e.g.
// Vineyard).
- // +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:UniqueItems=false
// +optional
Mounts []Mount `json:"mounts,omitempty"`
+ // AllowEmptyMounts indicates whether Mounts can be empty
+ // +optional
+ AllowEmptyMounts bool `json:"allowEmptyMounts,omitempty"`
+
// The owner of the dataset
// +optional
Owner *User `json:"owner,omitempty"`
diff --git a/charts/fluid/fluid/crds/data.fluid.io_datasets.yaml b/charts/fluid/fluid/crds/data.fluid.io_datasets.yaml
index 7780e3e84a8..45036e4b5d3 100644
--- a/charts/fluid/fluid/crds/data.fluid.io_datasets.yaml
+++ b/charts/fluid/fluid/crds/data.fluid.io_datasets.yaml
@@ -80,6 +80,9 @@ spec:
items:
type: string
type: array
+ allowEmptyMounts:
+ description: AllowEmptyMounts indicates whether Mounts can be empty
+ type: boolean
dataRestoreLocation:
description: DataRestoreLocation is the location to load data of dataset been
backuped
@@ -159,7 +162,6 @@ spec:
required:
- mountPoint
type: object
- minItems: 1
type: array
nodeAffinity:
description: |-
@@ -378,6 +380,11 @@ spec:
type: object
type: array
type: object
+ x-kubernetes-validations:
+ - message: Mounts must have at least one item unless AllowEmptyMounts
+ is true
+ rule: self.allowEmptyMounts == true || (has(self.mounts) && size(self.mounts)
+ >= 1)
status:
description: DatasetStatus defines the observed state of Dataset
properties:
diff --git a/config/crd/bases/data.fluid.io_datasets.yaml b/config/crd/bases/data.fluid.io_datasets.yaml
index 7780e3e84a8..45036e4b5d3 100644
--- a/config/crd/bases/data.fluid.io_datasets.yaml
+++ b/config/crd/bases/data.fluid.io_datasets.yaml
@@ -80,6 +80,9 @@ spec:
items:
type: string
type: array
+ allowEmptyMounts:
+ description: AllowEmptyMounts indicates whether Mounts can be empty
+ type: boolean
dataRestoreLocation:
description: DataRestoreLocation is the location to load data of dataset been
backuped
@@ -159,7 +162,6 @@ spec:
required:
- mountPoint
type: object
- minItems: 1
type: array
nodeAffinity:
description: |-
@@ -378,6 +380,11 @@ spec:
type: object
type: array
type: object
+ x-kubernetes-validations:
+ - message: Mounts must have at least one item unless AllowEmptyMounts
+ is true
+ rule: self.allowEmptyMounts == true || (has(self.mounts) && size(self.mounts)
+ >= 1)
status:
description: DatasetStatus defines the observed state of Dataset
properties: