Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`<br />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`<br />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 |



Expand All @@ -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`<br />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`<br />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 |



Expand All @@ -2675,7 +2675,7 @@ scw instance ssh list-keys <server-id ...> [arg=value ...]
| Name | | Description |
|------|---|-------------|
| server-id | Required | Server to add your key to |
| zone | Default: `fr-par-1`<br />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`<br />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 |



Expand All @@ -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`<br />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`<br />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 |



Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions internal/namespaces/instance/v1/custom_server_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)))
}

Expand All @@ -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,
Expand Down