Skip to content

Commit

Permalink
add name length validation for driver
Browse files Browse the repository at this point in the history
Choosing an arbitary length which is
56 for the csi driver name and adding
a validation to block CR creation if
the name is having more chars.

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 committed Aug 6, 2024
1 parent 6d04e9e commit ed8a5f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ type DriverStatus struct {
//+kubebuilder:subresource:status

// +kubebuilder:validation:XValidation:rule=self.metadata.name.matches('^(.+\\.)?(rbd|cephfs|nfs)?\\.csi\\.ceph\\.com$'),message=".metadata.name must match: '[<prefix>.](rbd|cephfs|nfs).csi.ceph.com'"
// +kubebuilder:validation:XValidation:rule="self.metadata.name.size() <= 56",message=".metadata.name must be no more than 56 characters"
// Driver is the Schema for the drivers API
type Driver struct {
metav1.TypeMeta `json:",inline"`
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/csi.ceph.io_drivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6788,6 +6788,8 @@ spec:
x-kubernetes-validations:
- message: '.metadata.name must match: ''[<prefix>.](rbd|cephfs|nfs).csi.ceph.com'''
rule: self.metadata.name.matches('^(.+\\.)?(rbd|cephfs|nfs)?\\.csi\\.ceph\\.com$')
- message: .metadata.name must be no more than 56 characters
rule: self.metadata.name.size() <= 56
served: true
storage: true
subresources:
Expand Down

0 comments on commit ed8a5f1

Please sign in to comment.