Skip to content

Commit cf9a0b3

Browse files
author
Quentin Perez
authored
Merge pull request #423 from QuentinPerez/fix-volume-size
Fix volume size
2 parents cbdd077 + 15a3490 commit cf9a0b3

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
12071207

12081208
### v1.10.1 (2016-10-24)
12091209

1210+
* `scw image -a -f type=volume` fix unmarshal error on size field
12101211
* `scw login` fix CheckCredentials ([418](https://github.com/scaleway/scaleway-cli/issues/418))
12111212

12121213
View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v1.10...v1.10.1)

pkg/api/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type ScalewayVolume struct {
142142
Identifier string `json:"id,omitempty"`
143143

144144
// Size is the allocated size of the volume
145-
Size uint64 `json:"size,omitempty"`
145+
Size interface{} `json:"size,omitempty"`
146146

147147
// CreationDate is the creation date of the volume
148148
CreationDate string `json:"creation_date,omitempty"`
@@ -1667,6 +1667,7 @@ func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error) {
16671667
if err != nil {
16681668
return nil, err
16691669
}
1670+
16701671
var volumes ScalewayVolumes
16711672

16721673
if err = json.Unmarshal(body, &volumes); err != nil {

pkg/api/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) {
445445
return "", err
446446
}
447447
currentVolume := createdServer.Volumes["0"]
448+
size := currentVolume.Size.(uint64)
448449

449450
var volumePayload ScalewayVolumePutDefinition
450451
newName := fmt.Sprintf("%s-%s", createdServer.Hostname, currentVolume.Name)
@@ -454,7 +455,7 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) {
454455
volumePayload.Server.Identifier = &currentVolume.Server.Identifier
455456
volumePayload.Server.Name = &currentVolume.Server.Name
456457
volumePayload.Identifier = &currentVolume.Identifier
457-
volumePayload.Size = &currentVolume.Size
458+
volumePayload.Size = &size
458459
volumePayload.ModificationDate = &currentVolume.ModificationDate
459460
volumePayload.ExportURI = &currentVolume.ExportURI
460461
volumePayload.VolumeType = &currentVolume.VolumeType

pkg/commands/history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func RunHistory(ctx CommandContext, args HistoryArgs) error {
5050
creationDateStr := units.HumanDuration(time.Now().UTC().Sub(creationDate))
5151

5252
volumeName := utils.TruncIf(image.RootVolume.Name, 25, !args.NoTrunc)
53-
size := units.HumanSize(float64(image.RootVolume.Size))
53+
size := units.HumanSize(image.RootVolume.Size.(float64))
5454

5555
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", identifier, creationDateStr, volumeName, size)
5656
return nil

pkg/commands/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
153153
Identifier: val.Identifier,
154154
Name: val.Name,
155155
Tag: "<volume>",
156-
VirtualSize: float64(val.Size),
156+
VirtualSize: val.Size.(float64),
157157
Public: false,
158158
Organization: val.Organization,
159159
// FIXME the region should not be hardcoded

0 commit comments

Comments
 (0)