Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat committed Dec 3, 2024
1 parent c1d79d5 commit c498cee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion api/core/v1alpha2/virtual_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ type VirtualImageList struct {
Items []VirtualImage `json:"items"`
}

// +kubebuilder:validation:XValidation:rule="self.storage == 'ContainerRegistry' ? !has(self.persistentVolumeClaim) && has(self.dataSource): true",message="The storage type ContainerRegistry should contain only the dataSource."
// +kubebuilder:validation:XValidation:rule="self.storage == 'PersistentVolumeClaim' ? !has(self.dataSource) && has(self.persistentVolumeClaim): true",message="The storage type PersistentVolumeClaim should contain only the persistentVolumeClaim."
// +kubebuilder:validation:XValidation:rule="self.storage == 'Kubernetes' ? !has(self.dataSource) && has(self.persistentVolumeClaim): true",message="The storage type Kubernetes should contain only the persistentVolumeClaim."
type VirtualImageSpec struct {
// +kubebuilder:default:=ContainerRegistry
Storage StorageType `json:"storage"`
PersistentVolumeClaim VirtualImagePersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"`
DataSource VirtualImageDataSource `json:"dataSource"`
DataSource VirtualImageDataSource `json:"dataSource,omitempty"`
}

type VirtualImageStatus struct {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion crds/virtualimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,25 @@ spec:
- PersistentVolumeClaim
type: string
required:
- dataSource
- storage
type: object
x-kubernetes-validations:
- message:
The storage type ContainerRegistry should contain only the
dataSource.
rule:
"self.storage == 'ContainerRegistry' ? !has(self.persistentVolumeClaim)
&& has(self.dataSource): true"
- message:
The storage type PersistentVolumeClaim should contain only
the persistentVolumeClaim.
rule:
"self.storage == 'PersistentVolumeClaim' ? !has(self.dataSource)
&& has(self.persistentVolumeClaim): true"
- message: The storage type Kubernetes should contain only the persistentVolumeClaim.
rule:
"self.storage == 'Kubernetes' ? !has(self.dataSource) && has(self.persistentVolumeClaim):
true"
status:
properties:
cdrom:
Expand Down

0 comments on commit c498cee

Please sign in to comment.