Skip to content

Commit 2a38627

Browse files
committed
fix(instance): display sbs volumes' size in instance image list details
1 parent ae7b686 commit 2a38627

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

internal/namespaces/instance/v1/custom_image.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func imageListBuilder(c *core.Command) *core.Command {
191191
req.Public = scw.BoolPtr(false)
192192
client := core.ExtractClient(ctx)
193193
api := instance.NewAPI(client)
194+
blockAPI := block.NewAPI(client)
194195

195196
opts := []scw.RequestOption{scw.WithAllPages()}
196197
if req.Zone == scw.Zone(core.AllLocalities) {
@@ -210,6 +211,33 @@ func imageListBuilder(c *core.Command) *core.Command {
210211
newCustomImage := &imageListItem{
211212
Image: image,
212213
}
214+
215+
if image.RootVolume.VolumeType == instance.VolumeVolumeTypeSbsSnapshot {
216+
blockVolume, err := blockAPI.GetSnapshot(&block.GetSnapshotRequest{
217+
SnapshotID: image.RootVolume.ID,
218+
Zone: image.Zone,
219+
}, scw.WithContext(ctx))
220+
if err != nil {
221+
return nil, err
222+
}
223+
224+
newCustomImage.Image.RootVolume.Size = blockVolume.Size
225+
}
226+
227+
for index, volume := range image.ExtraVolumes {
228+
if volume.VolumeType == instance.VolumeVolumeTypeSbsSnapshot {
229+
blockVolume, err := blockAPI.GetSnapshot(&block.GetSnapshotRequest{
230+
SnapshotID: volume.ID,
231+
Zone: volume.Zone,
232+
}, scw.WithContext(ctx))
233+
if err != nil {
234+
return nil, err
235+
}
236+
237+
newCustomImage.Image.ExtraVolumes[index].Size = blockVolume.Size
238+
}
239+
}
240+
213241
customImages = append(customImages, newCustomImage)
214242

215243
if image.FromServer == "" {

0 commit comments

Comments
 (0)