CSI: fix decoding error on snapshot create

Consumers of the CSI HTTP API are expecting a response object and not a slice
of snapshots. Fix the return value.
This commit is contained in:
Tim Gross 2021-04-07 08:44:12 -04:00 committed by Tim Gross
parent d2e479505c
commit 8af5bd1ad4
4 changed files with 6 additions and 6 deletions

View File

@ -115,13 +115,13 @@ func (v *CSIVolumes) Detach(volID, nodeID string, w *WriteOptions) error {
}
// CreateSnapshot snapshots an external storage volume.
func (v *CSIVolumes) CreateSnapshot(snap *CSISnapshot, w *WriteOptions) ([]*CSISnapshot, *WriteMeta, error) {
func (v *CSIVolumes) CreateSnapshot(snap *CSISnapshot, w *WriteOptions) (*CSISnapshotCreateResponse, *WriteMeta, error) {
req := &CSISnapshotCreateRequest{
Snapshots: []*CSISnapshot{snap},
}
resp := &CSISnapshotCreateResponse{}
meta, err := v.client.write("/v1/volumes/snapshot", req, resp, w)
return resp.Snapshots, meta, err
return resp, meta, err
}
// DeleteSnapshot deletes an external storage volume snapshot.

View File

@ -292,7 +292,7 @@ func (s *HTTPServer) csiSnapshotCreate(resp http.ResponseWriter, req *http.Reque
}
setMeta(resp, &out.QueryMeta)
return out.Snapshots, nil
return out, nil
}
func (s *HTTPServer) csiSnapshotDelete(resp http.ResponseWriter, req *http.Request) (interface{}, error) {

View File

@ -106,6 +106,6 @@ func (c *VolumeSnapshotCreateCommand) Run(args []string) int {
return 1
}
c.Ui.Output(csiFormatSnapshots(snaps, verbose))
c.Ui.Output(csiFormatSnapshots(snaps.Snapshots, verbose))
return 0
}

View File

@ -115,13 +115,13 @@ func (v *CSIVolumes) Detach(volID, nodeID string, w *WriteOptions) error {
}
// CreateSnapshot snapshots an external storage volume.
func (v *CSIVolumes) CreateSnapshot(snap *CSISnapshot, w *WriteOptions) ([]*CSISnapshot, *WriteMeta, error) {
func (v *CSIVolumes) CreateSnapshot(snap *CSISnapshot, w *WriteOptions) (*CSISnapshotCreateResponse, *WriteMeta, error) {
req := &CSISnapshotCreateRequest{
Snapshots: []*CSISnapshot{snap},
}
resp := &CSISnapshotCreateResponse{}
meta, err := v.client.write("/v1/volumes/snapshot", req, resp, w)
return resp.Snapshots, meta, err
return resp, meta, err
}
// DeleteSnapshot deletes an external storage volume snapshot.