mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 00:10:20 +00:00
util: add helper to validate ROX request
added a helper function to validate is create request for ROX is for volume from source. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
b4693dcffe
commit
d816df4f42
@ -78,3 +78,16 @@ func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) err
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckReadOnlyManyIsSupported checks the request is to create ReadOnlyMany
|
||||||
|
// volume is from source as empty ReadOnlyMany is not supported.
|
||||||
|
func CheckReadOnlyManyIsSupported(req *csi.CreateVolumeRequest) error {
|
||||||
|
for _, cap := range req.GetVolumeCapabilities() {
|
||||||
|
if m := cap.GetAccessMode().Mode; m == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY || m == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY {
|
||||||
|
if req.GetVolumeContentSource() == nil {
|
||||||
|
return status.Error(codes.InvalidArgument, "readOnly accessMode is supported only with content source")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user