diff --git a/cmd/scw/testdata/test-all-usage-instance-ssh-add-key-usage.golden b/cmd/scw/testdata/test-all-usage-instance-ssh-add-key-usage.golden index aec6e4788..ef97b5109 100644 --- a/cmd/scw/testdata/test-all-usage-instance-ssh-add-key-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-ssh-add-key-usage.golden @@ -11,7 +11,7 @@ USAGE: ARGS: [server-id] Server to add your key to [public-key] Public key you want to add to your server - [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2) FLAGS: -h, --help help for add-key diff --git a/cmd/scw/testdata/test-all-usage-instance-ssh-install-config-usage.golden b/cmd/scw/testdata/test-all-usage-instance-ssh-install-config-usage.golden index 50113f670..3677c2488 100644 --- a/cmd/scw/testdata/test-all-usage-instance-ssh-install-config-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-ssh-install-config-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: [project-id] Project ID to use. If none is passed the default project ID will be used - [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2) FLAGS: -h, --help help for install-config diff --git a/cmd/scw/testdata/test-all-usage-instance-ssh-list-keys-usage.golden b/cmd/scw/testdata/test-all-usage-instance-ssh-list-keys-usage.golden index dd8901326..eb4f19997 100644 --- a/cmd/scw/testdata/test-all-usage-instance-ssh-list-keys-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-ssh-list-keys-usage.golden @@ -9,7 +9,7 @@ USAGE: ARGS: server-id Server to add your key to - [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2) FLAGS: -h, --help help for list-keys diff --git a/cmd/scw/testdata/test-all-usage-instance-ssh-remove-key-usage.golden b/cmd/scw/testdata/test-all-usage-instance-ssh-remove-key-usage.golden index 718a791c4..63d9548b1 100644 --- a/cmd/scw/testdata/test-all-usage-instance-ssh-remove-key-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-ssh-remove-key-usage.golden @@ -11,7 +11,7 @@ ARGS: server-id Server to add your key to [name] Name of the key you want to remove, has to be the key comment or the index [public-key] Public key you want to remove - [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2) FLAGS: -h, --help help for remove-key diff --git a/docs/commands/instance.md b/docs/commands/instance.md index 1b7035a45..ab596bd88 100644 --- a/docs/commands/instance.md +++ b/docs/commands/instance.md @@ -2632,7 +2632,7 @@ scw instance ssh add-key [arg=value ...] |------|---|-------------| | server-id | | Server to add your key to | | public-key | | Public key you want to add to your server | -| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | @@ -2653,7 +2653,7 @@ scw instance ssh install-config [arg=value ...] | Name | | Description | |------|---|-------------| | project-id | | Project ID to use. If none is passed the default project ID will be used | -| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | @@ -2675,7 +2675,7 @@ scw instance ssh list-keys [arg=value ...] | Name | | Description | |------|---|-------------| | server-id | Required | Server to add your key to | -| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | @@ -2699,7 +2699,7 @@ scw instance ssh remove-key [arg=value ...] | server-id | Required | Server to add your key to | | name | | Name of the key you want to remove, has to be the key comment or the index | | public-key | | Public key you want to remove | -| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | diff --git a/go.mod b/go.mod index f135b0fa4..71e08d59c 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/moby/buildkit v0.11.6 github.com/opencontainers/go-digest v1.0.0 github.com/pkg/errors v0.9.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230614162946-6279e7999742 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230619154501-6a12f2ddaa47 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 4be5d8b3e..d5924bcb8 100644 --- a/go.sum +++ b/go.sum @@ -497,8 +497,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230614162946-6279e7999742 h1:tYilRVnAW/yYmlMOmMrU1zZuIPcCuNmpLmnHXMZV1vs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230614162946-6279e7999742/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230619154501-6a12f2ddaa47 h1:eGARFgFhRDgxFF6QwimHe+MV21xhuPKLPNhJyML3JkA= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17.0.20230619154501-6a12f2ddaa47/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 38012a685..cb7f73206 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -287,8 +287,8 @@ func serverUpdateBuilder(c *core.Command) *core.Command { for i, volumeID := range *customRequest.VolumeIDs { index := strconv.Itoa(i) volumes[index] = &instance.VolumeServerTemplate{ - ID: volumeID, - Name: getServerResponse.Server.Name + "-" + index, + ID: scw.StringPtr(volumeID), + Name: scw.StringPtr(getServerResponse.Server.Name + "-" + index), } } customRequest.Volumes = &volumes diff --git a/internal/namespaces/instance/v1/custom_server_create.go b/internal/namespaces/instance/v1/custom_server_create.go index c664fdb5e..79df5cd34 100644 --- a/internal/namespaces/instance/v1/custom_server_create.go +++ b/internal/namespaces/instance/v1/custom_server_create.go @@ -447,10 +447,10 @@ func buildVolumes(api *instance.API, zone scw.Zone, serverName, rootVolume strin return nil, err } index := strconv.Itoa(i + 1) - volumeTemplate.Name = serverName + "-" + index + volumeTemplate.Name = scw.StringPtr(serverName + "-" + index) // Remove extra data for API validation. - if volumeTemplate.ID != "" { + if volumeTemplate.ID != nil { volumeTemplate = &instance.VolumeServerTemplate{ ID: volumeTemplate.ID, Name: volumeTemplate.Name, @@ -495,7 +495,7 @@ func buildVolumeTemplate(api *instance.API, zone scw.Zone, flagV string) (*insta if err != nil { return nil, fmt.Errorf("invalid size format %s in %s volume", parts[1], flagV) } - vt.Size = scw.Size(size) + vt.Size = scw.SizePtr(scw.Size(size)) return vt, nil } @@ -534,9 +534,9 @@ func buildVolumeTemplateFromUUID(api *instance.API, zone scw.Zone, volumeUUID st } return &instance.VolumeServerTemplate{ - ID: res.Volume.ID, + ID: &res.Volume.ID, VolumeType: res.Volume.VolumeType, - Size: res.Volume.Size, + Size: &res.Volume.Size, }, nil } @@ -562,10 +562,10 @@ func buildVolumeTemplateFromSnapshot(api *instance.API, zone scw.Zone, snapshotU } return &instance.VolumeServerTemplate{ - Name: res.Snapshot.Name, + Name: &res.Snapshot.Name, VolumeType: volumeType, - BaseSnapshot: res.Snapshot.ID, - Size: res.Snapshot.Size, + BaseSnapshot: &res.Snapshot.ID, + Size: &res.Snapshot.Size, }, nil } @@ -592,8 +592,8 @@ func validateLocalVolumeSizes(volumes map[string]*instance.VolumeServerTemplate, // Calculate local volume total size. var localVolumeTotalSize scw.Size for _, volume := range volumes { - if volume.VolumeType == instance.VolumeVolumeTypeLSSD { - localVolumeTotalSize += volume.Size + if volume.VolumeType == instance.VolumeVolumeTypeLSSD && volume.Size != nil { + localVolumeTotalSize += *volume.Size } } @@ -622,14 +622,14 @@ func validateRootVolume(imageRequiredSize scw.Size, rootVolume *instance.VolumeS return nil } - if rootVolume.ID != "" { + if rootVolume.ID != nil { return &core.CliError{ Err: fmt.Errorf("you cannot use an existing volume as a root volume"), Details: "You must create an image of this volume and use its ID in the 'image' argument.", } } - if rootVolume.Size < imageRequiredSize { + if rootVolume.Size != nil && *rootVolume.Size < imageRequiredSize { return fmt.Errorf("first volume size must be at least %s for this image", humanize.Bytes(uint64(imageRequiredSize))) } @@ -641,22 +641,22 @@ func sanitizeVolumeMap(serverName string, volumes map[string]*instance.VolumeSer m := make(map[string]*instance.VolumeServerTemplate) for index, v := range volumes { - v.Name = serverName + "-" + index + v.Name = scw.StringPtr(serverName + "-" + index) // Remove extra data for API validation. switch { - case v.ID != "": + case v.ID != nil: v = &instance.VolumeServerTemplate{ ID: v.ID, Name: v.Name, } - case v.BaseSnapshot != "": + case v.BaseSnapshot != nil: v = &instance.VolumeServerTemplate{ BaseSnapshot: v.BaseSnapshot, Name: v.Name, VolumeType: v.VolumeType, } - case index == "0" && v.Size != 0: + case index == "0" && v.Size != nil: v = &instance.VolumeServerTemplate{ VolumeType: v.VolumeType, Size: v.Size,