csi: Nil check ToCSIRepresentation implementations

This commit is contained in:
Danielle Lancashire 2020-01-25 10:39:21 +01:00 committed by Tim Gross
parent 02c4612e65
commit a4b96aff33

View file

@ -101,6 +101,10 @@ type NodePublishVolumeRequest struct {
} }
func (r *NodePublishVolumeRequest) ToCSIRepresentation() *csipbv1.NodePublishVolumeRequest { func (r *NodePublishVolumeRequest) ToCSIRepresentation() *csipbv1.NodePublishVolumeRequest {
if r == nil {
return nil
}
return &csipbv1.NodePublishVolumeRequest{ return &csipbv1.NodePublishVolumeRequest{
VolumeId: r.VolumeID, VolumeId: r.VolumeID,
PublishContext: r.PublishContext, PublishContext: r.PublishContext,
@ -325,6 +329,10 @@ type VolumeCapability struct {
} }
func (c *VolumeCapability) ToCSIRepresentation() *csipbv1.VolumeCapability { func (c *VolumeCapability) ToCSIRepresentation() *csipbv1.VolumeCapability {
if c == nil {
return nil
}
vc := &csipbv1.VolumeCapability{ vc := &csipbv1.VolumeCapability{
AccessMode: &csipbv1.VolumeCapability_AccessMode{ AccessMode: &csipbv1.VolumeCapability_AccessMode{
Mode: c.AccessMode.ToCSIRepresentation(), Mode: c.AccessMode.ToCSIRepresentation(),