@@ -157,6 +157,7 @@ func imageCreateBuilder(c *core.Command) *core.Command {
157
157
// customImage is based on instance.Image, with additional information about the server
158
158
type imageListItem struct {
159
159
* instance.Image
160
+ Volumes map [string ]* instance.Volume
160
161
161
162
// Replace Image.FromServer
162
163
ServerID string `json:"server_id"`
@@ -191,6 +192,7 @@ func imageListBuilder(c *core.Command) *core.Command {
191
192
req .Public = scw .BoolPtr (false )
192
193
client := core .ExtractClient (ctx )
193
194
api := instance .NewAPI (client )
195
+ blockAPI := block .NewAPI (client )
194
196
195
197
opts := []scw.RequestOption {scw .WithAllPages ()}
196
198
if req .Zone == scw .Zone (core .AllLocalities ) {
@@ -210,6 +212,33 @@ func imageListBuilder(c *core.Command) *core.Command {
210
212
newCustomImage := & imageListItem {
211
213
Image : image ,
212
214
}
215
+
216
+ if image .RootVolume .VolumeType == instance .VolumeVolumeTypeSbsSnapshot {
217
+ blockVolume , err := blockAPI .GetSnapshot (& block.GetSnapshotRequest {
218
+ SnapshotID : image .RootVolume .ID ,
219
+ Zone : image .Zone ,
220
+ }, scw .WithContext (ctx ))
221
+ if err != nil {
222
+ return nil , err
223
+ }
224
+
225
+ newCustomImage .Image .RootVolume .Size = blockVolume .Size
226
+ }
227
+
228
+ for index , volume := range image .ExtraVolumes {
229
+ if volume .VolumeType == instance .VolumeVolumeTypeSbsSnapshot {
230
+ blockVolume , err := blockAPI .GetSnapshot (& block.GetSnapshotRequest {
231
+ SnapshotID : volume .ID ,
232
+ Zone : volume .Zone ,
233
+ }, scw .WithContext (ctx ))
234
+ if err != nil {
235
+ return nil , err
236
+ }
237
+
238
+ newCustomImage .Image .ExtraVolumes [index ].Size = blockVolume .Size
239
+ }
240
+ }
241
+
213
242
customImages = append (customImages , newCustomImage )
214
243
215
244
if image .FromServer == "" {
0 commit comments