Skip to content

Commit

Permalink
api: make storageClassClaim immutable
Browse files Browse the repository at this point in the history
add kubebuilder validations to make storageClassClaim spec
immutable

Signed-off-by: Rewant Soni <[email protected]>
  • Loading branch information
rewantsoni committed Feb 8, 2024
1 parent 4a52d27 commit 35bcfdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/v1alpha1/storageclassclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ type StorageClassClaim struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec StorageClassClaimSpec `json:"spec,omitempty"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="oldSelf == self",message="spec is immutable"
Spec StorageClassClaimSpec `json:"spec"`
Status StorageClassClaimStatus `json:"status,omitempty"`
}

Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageclassclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ spec:
- storageClient
- type
type: object
x-kubernetes-validations:
- message: spec is immutable
rule: oldSelf == self
status:
description: StorageClassClaimStatus defines the observed state of StorageClassClaim
properties:
Expand All @@ -84,6 +87,8 @@ spec:
type: string
type: array
type: object
required:
- spec
type: object
served: true
storage: true
Expand Down

0 comments on commit 35bcfdd

Please sign in to comment.