Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vi): update CEL #549

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading