Skip to content

Commit

Permalink
api: replace storage.VolumeMeta with VolumeMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed May 4, 2023
1 parent c417ebe commit 6994bd8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (a *api) handleGETVolume(c jape.Context) {
} else if !a.checkServerError(c, "failed to get volume", err) {
return
}
c.Encode(volume)
c.Encode(toJSONVolume(volume))
}

func (a *api) handlePUTVolume(c jape.Context) {
Expand Down Expand Up @@ -280,7 +280,11 @@ func (a *api) handleGETVolumes(c jape.Context) {
if !a.checkServerError(c, "failed to get volumes", err) {
return
}
c.Encode(volumes)
var jsonVolumes []VolumeMeta
for _, volume := range volumes {
jsonVolumes = append(jsonVolumes, toJSONVolume(volume))
}
c.Encode(jsonVolumes)
}

func (a *api) handlePOSTVolume(c jape.Context) {
Expand Down Expand Up @@ -486,3 +490,13 @@ func parseLimitParams(c jape.Context, defaultLimit, maxLimit int) (limit, offset
}
return
}

func toJSONVolume(vol storage.VolumeMeta) VolumeMeta {
jvm := VolumeMeta{
VolumeMeta: vol,
}
for _, err := range vol.Errors {
jvm.Errors = append(jvm.Errors, err)
}
return jvm
}

0 comments on commit 6994bd8

Please sign in to comment.