csi: add missing fields to HTTP API response (#12178)
The HTTP endpoint for CSI manually serializes the internal struct to the API struct for purposes of redaction (see also #10470). Add fields that were missing from this serialization so they don't show up as always empty in the API response.
This commit is contained in:
parent
fe38da1137
commit
3247e422d1
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
csi: Fixed a bug where fields were missing from the Read Volume API response
|
||||||
|
```
|
|
@ -479,6 +479,7 @@ func structsCSIVolumeToApi(vol *structs.CSIVolume) *api.CSIVolume {
|
||||||
Name: vol.Name,
|
Name: vol.Name,
|
||||||
ExternalID: vol.ExternalID,
|
ExternalID: vol.ExternalID,
|
||||||
Namespace: vol.Namespace,
|
Namespace: vol.Namespace,
|
||||||
|
|
||||||
Topologies: structsCSITopolgiesToApi(vol.Topologies),
|
Topologies: structsCSITopolgiesToApi(vol.Topologies),
|
||||||
AccessMode: structsCSIAccessModeToApi(vol.AccessMode),
|
AccessMode: structsCSIAccessModeToApi(vol.AccessMode),
|
||||||
AttachmentMode: structsCSIAttachmentModeToApi(vol.AttachmentMode),
|
AttachmentMode: structsCSIAttachmentModeToApi(vol.AttachmentMode),
|
||||||
|
@ -486,6 +487,13 @@ func structsCSIVolumeToApi(vol *structs.CSIVolume) *api.CSIVolume {
|
||||||
Secrets: structsCSISecretsToApi(vol.Secrets),
|
Secrets: structsCSISecretsToApi(vol.Secrets),
|
||||||
Parameters: vol.Parameters,
|
Parameters: vol.Parameters,
|
||||||
Context: vol.Context,
|
Context: vol.Context,
|
||||||
|
Capacity: vol.Capacity,
|
||||||
|
|
||||||
|
RequestedCapacityMin: vol.RequestedCapacityMin,
|
||||||
|
RequestedCapacityMax: vol.RequestedCapacityMax,
|
||||||
|
RequestedCapabilities: structsCSICapabilityToApi(vol.RequestedCapabilities),
|
||||||
|
CloneID: vol.CloneID,
|
||||||
|
SnapshotID: vol.SnapshotID,
|
||||||
|
|
||||||
// Allocations is the collapsed list of both read and write allocs
|
// Allocations is the collapsed list of both read and write allocs
|
||||||
Allocations: make([]*api.AllocationListStub, 0, allocCount),
|
Allocations: make([]*api.AllocationListStub, 0, allocCount),
|
||||||
|
@ -772,6 +780,18 @@ func structsCSIAttachmentModeToApi(mode structs.CSIVolumeAttachmentMode) api.CSI
|
||||||
return api.CSIVolumeAttachmentModeUnknown
|
return api.CSIVolumeAttachmentModeUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// structsCSICapabilityToApi converts capabilities, part of structsCSIVolumeToApi
|
||||||
|
func structsCSICapabilityToApi(caps []*structs.CSIVolumeCapability) []*api.CSIVolumeCapability {
|
||||||
|
out := make([]*api.CSIVolumeCapability, len(caps))
|
||||||
|
for i, cap := range caps {
|
||||||
|
out[i] = &api.CSIVolumeCapability{
|
||||||
|
AccessMode: api.CSIVolumeAccessMode(cap.AccessMode),
|
||||||
|
AttachmentMode: api.CSIVolumeAttachmentMode(cap.AttachmentMode),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// structsCSIMountOptionsToApi converts mount options, part of structsCSIVolumeToApi
|
// structsCSIMountOptionsToApi converts mount options, part of structsCSIVolumeToApi
|
||||||
func structsCSIMountOptionsToApi(opts *structs.CSIMountOptions) *api.CSIMountOptions {
|
func structsCSIMountOptionsToApi(opts *structs.CSIMountOptions) *api.CSIMountOptions {
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
|
|
Loading…
Reference in New Issue