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 @@ -27,7 +27,7 @@ EXAMPLES:

ARGS:
image=ubuntu_jammy Image ID or label of the server
type=DEV1-S Server commercial type (GP1-XS | GP1-S | GP1-M | GP1-L | GP1-XL | DEV1-S | DEV1-M | DEV1-L | DEV1-XL | RENDER-S | STARDUST1-S | ENT1-XXS | ENT1-XS | ENT1-S | ENT1-M | ENT1-L | ENT1-XL | ENT1-2XL | PRO2-XXS | PRO2-XS | PRO2-S | PRO2-M | PRO2-L | PLAY2-PICO | PLAY2-NANO | PLAY2-MICRO | GPU-3070-S)
type=DEV1-S Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)
[name=<generated>] Server name
[root-volume] Local root volume of the server
[additional-volumes.{index}] Additional local and block volumes attached to your server
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ scw instance server create [arg=value ...]
| Name | | Description |
|------|---|-------------|
| image | Required<br />Default: `ubuntu_jammy` | Image ID or label of the server |
| type | Required<br />Default: `DEV1-S`<br />One of: `GP1-XS`, `GP1-S`, `GP1-M`, `GP1-L`, `GP1-XL`, `DEV1-S`, `DEV1-M`, `DEV1-L`, `DEV1-XL`, `RENDER-S`, `STARDUST1-S`, `ENT1-XXS`, `ENT1-XS`, `ENT1-S`, `ENT1-M`, `ENT1-L`, `ENT1-XL`, `ENT1-2XL`, `PRO2-XXS`, `PRO2-XS`, `PRO2-S`, `PRO2-M`, `PRO2-L`, `PLAY2-PICO`, `PLAY2-NANO`, `PLAY2-MICRO`, `GPU-3070-S` | Server commercial type |
| type | Required<br />Default: `DEV1-S` | Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/) |
| name | Default: `<generated>` | Server name |
| root-volume | | Local root volume of the server |
| additional-volumes.{index} | | Additional local and block volumes attached to your server |
Expand Down
32 changes: 2 additions & 30 deletions internal/namespaces/instance/v1/custom_server_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,14 @@ func serverCreateCommand() *core.Command {
},
{
Name: "type",
Short: "Server commercial type",
Short: "Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)",
Default: core.DefaultValueSetter("DEV1-S"),
Required: true,
EnumValues: []string{
"GP1-XS",
"GP1-S",
"GP1-M",
"GP1-L",
"GP1-XL",
"DEV1-S",
"DEV1-M",
"DEV1-L",
"DEV1-XL",
"RENDER-S",
"STARDUST1-S",
"ENT1-XXS",
"ENT1-XS",
"ENT1-S",
"ENT1-M",
"ENT1-L",
"ENT1-XL",
"ENT1-2XL",
"PRO2-XXS",
"PRO2-XS",
"PRO2-S",
"PRO2-M",
"PRO2-L",
"PLAY2-PICO",
"PLAY2-NANO",
"PLAY2-MICRO",
"GPU-3070-S",
},
ValidateFunc: func(argSpec *core.ArgSpec, value interface{}) error {
// Allow all commercial types
return nil
},
AutoCompleteFunc: completeServerType,
},
{
Name: "name",
Expand Down
78 changes: 78 additions & 0 deletions internal/namespaces/instance/v1/helpers_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package instance

import (
"context"
"strings"

"github.com/scaleway/scaleway-cli/v2/internal/core"
)

var serverTypes = []string{
"GP1-XS",
"GP1-S",
"GP1-M",
"GP1-L",
"GP1-XL",

"DEV1-S",
"DEV1-M",
"DEV1-L",
"DEV1-XL",

"ENT1-XXS",
"ENT1-XS",
"ENT1-S",
"ENT1-M",
"ENT1-L",
"ENT1-XL",
"ENT1-2XL",

"RENDER-S",

"STARDUST1-S",

"GPU-3070-S",

"PRO2-XXS",
"PRO2-XS",
"PRO2-S",
"PRO2-M",
"PRO2-L",

"PLAY2-PICO",
"PLAY2-NANO",
"PLAY2-MICRO",

"POP2-2C-8G",
"POP2-4C-16G",
"POP2-8C-32G",
"POP2-16C-64G",
"POP2-32C-128G",
"POP2-64C-256G",

"POP2-HM-2C-16G",
"POP2-HM-4C-32G",
"POP2-HM-8C-64G",
"POP2-HM-16C-128G",
"POP2-HM-32C-256G",
"POP2-HM-64C-512G",

"POP2-HC-2C-4G",
"POP2-HC-4C-8G",
"POP2-HC-8C-16G",
"POP2-HC-16C-32G",
"POP2-HC-32C-63G",
"POP2-HC-64C-128G",
}

func completeServerType(_ context.Context, prefix string) core.AutocompleteSuggestions {
suggestions := []string(nil)

for _, serverType := range serverTypes {
if strings.HasPrefix(serverType, prefix) {
suggestions = append(suggestions, serverType)
}
}

return suggestions
}