Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cici37 committed May 6, 2024
1 parent 4d6c52e commit 982f11e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
19 changes: 10 additions & 9 deletions client/apis/volumegroupsnapshot/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type VolumeGroupSnapshotSpec struct {
// class will be used.
// Empty string is not allowed for this field.
// +optional
// +kubebuilder:validation:XValidation:rule="size(self) > 0",message="VolumeGroupSnapshotClassName must not be the empty string when set"
// +kubebuilder:validation:XValidation:rule="size(self) > 0",message="volumeGroupSnapshotClassName must not be the empty string when set"
VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotClassName"`
}

Expand All @@ -47,6 +47,7 @@ type VolumeGroupSnapshotSpec struct {
// Members in VolumeGroupSnapshotSource are immutable.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.selector) || has(self.selector)", message="selector is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeGroupSnapshotContentName) || has(self.volumeGroupSnapshotContentName)", message="volumeGroupSnapshotContentName is required once set"
// +kubebuilder:validation:XValidation:rule="(has(self.selector) && !has(self.volumeGroupSnapshotContentName)) || (!has(self.selector) && has(self.volumeGroupSnapshotContentName))", message="exactly one of selector and volumeGroupSnapshotContentName must be set"
type VolumeGroupSnapshotSource struct {
// Selector is a label query over persistent volume claims that are to be
// grouped together for snapshotting.
Expand All @@ -56,7 +57,7 @@ type VolumeGroupSnapshotSource struct {
// Once a VolumeGroupSnapshotContent is created and the sidecar starts to process
// it, the volume list will not change with retries.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.Selector is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="selector is immutable"
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`

// VolumeGroupSnapshotContentName specifies the name of a pre-existing VolumeGroupSnapshotContent
Expand All @@ -65,7 +66,7 @@ type VolumeGroupSnapshotSource struct {
// only needs a representation in Kubernetes.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.VolumeGroupSnapshotContentName is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotContentName is immutable"
VolumeGroupSnapshotContentName *string `json:"volumeGroupSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeGroupSnapshotContentName"`
}

Expand Down Expand Up @@ -270,9 +271,8 @@ type VolumeGroupSnapshotContentSpec struct {
// VolumeGroupSnapshot object MUST be provided for binding to happen.
// This field is immutable after creation.
// Required.
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both Spec.VolumeGroupSnapshotRef.Name and Spec.VolumeGroupSnapshotRef.Namespace must be set"
// +kubebuilder:validation:XValidation:rule="self.name == oldSelf.name",message="Spec.VolumeGroupSnapshotRef.Name is immutable"
// +kubebuilder:validation:XValidation:rule="self.__namespace__ == oldSelf.__namespace__",message="Spec.VolumeGroupSnapshotRef.Namespace is immutable"
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace must be set"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotRef is immutable"
VolumeGroupSnapshotRef core_v1.ObjectReference `json:"volumeGroupSnapshotRef" protobuf:"bytes,1,opt,name=volumeGroupSnapshotRef"`

// DeletionPolicy determines whether this VolumeGroupSnapshotContent and the
Expand Down Expand Up @@ -355,14 +355,15 @@ type VolumeGroupSnapshotContentStatus struct {
// VolumeGroupSnapshotContentSource represents the CSI source of a group snapshot.
// Exactly one of its members must be set.
// Members in VolumeGroupSnapshotContentSource are immutable.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeHandle) || has(self.volumeHandle)", message="volumeHandle is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeHandles) || has(self.volumeHandles)", message="volumeHandles is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.groupSnapshotHandles) || has(self.groupSnapshotHandles)", message="groupSnapshotHandles is required once set"
// +kubebuilder:validation:XValidation:rule="(has(self.volumeHandles) && !has(self.groupSnapshotHandles)) || (!has(self.volumeHandles) && has(self.groupSnapshotHandles))", message="exactly one of volumeHandles and groupSnapshotHandles must be set"
type VolumeGroupSnapshotContentSource struct {
// VolumeHandles is a list of volume handles on the backend to be snapshotted
// together. It is specified for dynamic provisioning of the VolumeGroupSnapshot.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.VolumeHandle is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeHandles is immutable"
VolumeHandles []string `json:"volumeHandles,omitempty" protobuf:"bytes,1,opt,name=volumeHandles"`

// GroupSnapshotHandles specifies the CSI "group_snapshot_id" of a pre-existing
Expand All @@ -371,7 +372,7 @@ type VolumeGroupSnapshotContentSource struct {
// representation was (or should be) created.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.GroupSnapshotHandles is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="groupSnapshotHandles is immutable"
GroupSnapshotHandles *GroupSnapshotHandles `json:"groupSnapshotHandles,omitempty" protobuf:"bytes,2,opt,name=groupSnapshotHandles"`
}

Expand Down
12 changes: 7 additions & 5 deletions client/apis/volumesnapshot/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type VolumeSnapshotSpec struct {
// Members in VolumeSnapshotSource are immutable.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.persistentVolumeClaimName) || has(self.persistentVolumeClaimName)", message="persistentVolumeClaimName is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeSnapshotContentName) || has(self.volumeSnapshotContentName)", message="volumeSnapshotContentName is required once set"
// +kubebuilder:validation:XValidation:rule="(has(self.volumeSnapshotContentName) && !has(self.persistentVolumeClaimName)) || (!has(self.volumeSnapshotContentName) && has(self.persistentVolumeClaimName))", message="exactly one of volumeSnapshotContentName and persistentVolumeClaimName must be set"
type VolumeSnapshotSource struct {
// persistentVolumeClaimName specifies the name of the PersistentVolumeClaim
// object representing the volume from which a snapshot should be created.
Expand All @@ -111,15 +112,15 @@ type VolumeSnapshotSource struct {
// created.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.PersistentVolumeClaimName is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="persistentVolumeClaimName is immutable"
PersistentVolumeClaimName *string `json:"persistentVolumeClaimName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeClaimName"`

// volumeSnapshotContentName specifies the name of a pre-existing VolumeSnapshotContent
// object representing an existing volume snapshot.
// This field should be set if the snapshot already exists and only needs a representation in Kubernetes.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.VolumeSnapshotContentName is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeSnapshotContentName is immutable"
VolumeSnapshotContentName *string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"`
}

Expand Down Expand Up @@ -347,7 +348,7 @@ type VolumeSnapshotContentSpec struct {
// This field is immutable.
// This field is an alpha field.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.sourceVolumeMode is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="sourceVolumeMode is immutable"
SourceVolumeMode *core_v1.PersistentVolumeMode `json:"sourceVolumeMode" protobuf:"bytes,6,opt,name=sourceVolumeMode"`
}

Expand All @@ -356,20 +357,21 @@ type VolumeSnapshotContentSpec struct {
// Members in VolumeSnapshotContentSource are immutable.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.volumeHandle) || has(self.volumeHandle)", message="volumeHandle is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.snapshotHandle) || has(self.snapshotHandle)", message="snapshotHandle is required once set"
// +kubebuilder:validation:XValidation:rule="(has(self.volumeHandle) && !has(self.snapshotHandle)) || (!has(self.volumeHandle) && has(self.snapshotHandle))", message="exactly one of volumeHandle and snapshotHandle must be set"
type VolumeSnapshotContentSource struct {
// volumeHandle specifies the CSI "volume_id" of the volume from which a snapshot
// should be dynamically taken from.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.VolumeHandle is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeHandle is immutable"
VolumeHandle *string `json:"volumeHandle,omitempty" protobuf:"bytes,1,opt,name=volumeHandle"`

// snapshotHandle specifies the CSI "snapshot_id" of a pre-existing snapshot on
// the underlying storage system for which a Kubernetes object representation
// was (or should be) created.
// This field is immutable.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Spec.Source.SnapshotHandle is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="snapshotHandle is immutable"
SnapshotHandle *string `json:"snapshotHandle,omitempty" protobuf:"bytes,2,opt,name=snapshotHandle"`
}

Expand Down

0 comments on commit 982f11e

Please sign in to comment.