diff --git a/README.md b/README.md index 6d9e6862c2..1877ab04b4 100644 --- a/README.md +++ b/README.md @@ -1203,6 +1203,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address' ### v1.10.1 (2016-10-24) +* `scw image -a -f type=volume` fix unmarshal error on size field * `scw login` fix CheckCredentials ([418](https://github.com/scaleway/scaleway-cli/issues/418)) View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v1.10...v1.10.1) diff --git a/pkg/api/api.go b/pkg/api/api.go index 2dc25dde90..55610cee58 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -142,7 +142,7 @@ type ScalewayVolume struct { Identifier string `json:"id,omitempty"` // Size is the allocated size of the volume - Size uint64 `json:"size,omitempty"` + Size interface{} `json:"size,omitempty"` // CreationDate is the creation date of the volume CreationDate string `json:"creation_date,omitempty"` @@ -1667,6 +1667,7 @@ func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error) { if err != nil { return nil, err } + var volumes ScalewayVolumes if err = json.Unmarshal(body, &volumes); err != nil { diff --git a/pkg/api/helpers.go b/pkg/api/helpers.go index 32c5419980..07eff4343a 100644 --- a/pkg/api/helpers.go +++ b/pkg/api/helpers.go @@ -445,6 +445,7 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) { return "", err } currentVolume := createdServer.Volumes["0"] + size := currentVolume.Size.(uint64) var volumePayload ScalewayVolumePutDefinition newName := fmt.Sprintf("%s-%s", createdServer.Hostname, currentVolume.Name) @@ -454,7 +455,7 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) { volumePayload.Server.Identifier = ¤tVolume.Server.Identifier volumePayload.Server.Name = ¤tVolume.Server.Name volumePayload.Identifier = ¤tVolume.Identifier - volumePayload.Size = ¤tVolume.Size + volumePayload.Size = &size volumePayload.ModificationDate = ¤tVolume.ModificationDate volumePayload.ExportURI = ¤tVolume.ExportURI volumePayload.VolumeType = ¤tVolume.VolumeType diff --git a/pkg/commands/history.go b/pkg/commands/history.go index d3abbdcab7..541e334b30 100644 --- a/pkg/commands/history.go +++ b/pkg/commands/history.go @@ -50,7 +50,7 @@ func RunHistory(ctx CommandContext, args HistoryArgs) error { creationDateStr := units.HumanDuration(time.Now().UTC().Sub(creationDate)) volumeName := utils.TruncIf(image.RootVolume.Name, 25, !args.NoTrunc) - size := units.HumanSize(float64(image.RootVolume.Size)) + size := units.HumanSize(image.RootVolume.Size.(float64)) fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", identifier, creationDateStr, volumeName, size) return nil diff --git a/pkg/commands/images.go b/pkg/commands/images.go index 4b8b93756e..ae3f4e0fce 100644 --- a/pkg/commands/images.go +++ b/pkg/commands/images.go @@ -153,7 +153,7 @@ func RunImages(ctx CommandContext, args ImagesArgs) error { Identifier: val.Identifier, Name: val.Name, Tag: "", - VirtualSize: float64(val.Size), + VirtualSize: val.Size.(float64), Public: false, Organization: val.Organization, // FIXME the region should not be hardcoded