Skip to content

Commit 9c047f5

Browse files
committed
modify response
1 parent c85fc4f commit 9c047f5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,26 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
193193
}
194194
}
195195

196+
createVolumeResponse := &csi.CreateVolumeResponse{}
196197
if req.GetVolumeContentSource() != nil {
197-
return &csi.CreateVolumeResponse{
198+
createVolumeResponse = &csi.CreateVolumeResponse{
198199
Volume: &csi.Volume{
199200
VolumeId: volumeID,
200201
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
201202
VolumeContext: req.GetParameters(),
202203
ContentSource: req.GetVolumeContentSource(),
203204
},
204-
}, nil
205+
}
206+
} else {
207+
createVolumeResponse = &csi.CreateVolumeResponse{
208+
Volume: &csi.Volume{
209+
VolumeId: volumeID,
210+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
211+
VolumeContext: req.GetParameters(),
212+
},
213+
}
205214
}
206-
207-
return &csi.CreateVolumeResponse{
208-
Volume: &csi.Volume{
209-
VolumeId: volumeID,
210-
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
211-
VolumeContext: req.GetParameters(),
212-
},
213-
}, nil
215+
return createVolumeResponse, nil
214216
}
215217

216218
func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {

0 commit comments

Comments
 (0)