Skip to content

Commit 9f7d740

Browse files
authored
feat(instance): add pop2 server types (#3183)
1 parent 2a99adb commit 9f7d740

File tree

4 files changed

+82
-32
lines changed

4 files changed

+82
-32
lines changed

cmd/scw/testdata/test-all-usage-instance-server-create-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ EXAMPLES:
2727

2828
ARGS:
2929
image=ubuntu_jammy Image ID or label of the server
30-
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)
30+
type=DEV1-S Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)
3131
[name=<generated>] Server name
3232
[root-volume] Local root volume of the server
3333
[additional-volumes.{index}] Additional local and block volumes attached to your server

docs/commands/instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ scw instance server create [arg=value ...]
16991699
| Name | | Description |
17001700
|------|---|-------------|
17011701
| image | Required<br />Default: `ubuntu_jammy` | Image ID or label of the server |
1702-
| 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 |
1702+
| type | Required<br />Default: `DEV1-S` | Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/) |
17031703
| name | Default: `<generated>` | Server name |
17041704
| root-volume | | Local root volume of the server |
17051705
| additional-volumes.{index} | | Additional local and block volumes attached to your server |

internal/namespaces/instance/v1/custom_server_create.go

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,14 @@ func serverCreateCommand() *core.Command {
5959
},
6060
{
6161
Name: "type",
62-
Short: "Server commercial type",
62+
Short: "Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)",
6363
Default: core.DefaultValueSetter("DEV1-S"),
6464
Required: true,
65-
EnumValues: []string{
66-
"GP1-XS",
67-
"GP1-S",
68-
"GP1-M",
69-
"GP1-L",
70-
"GP1-XL",
71-
"DEV1-S",
72-
"DEV1-M",
73-
"DEV1-L",
74-
"DEV1-XL",
75-
"RENDER-S",
76-
"STARDUST1-S",
77-
"ENT1-XXS",
78-
"ENT1-XS",
79-
"ENT1-S",
80-
"ENT1-M",
81-
"ENT1-L",
82-
"ENT1-XL",
83-
"ENT1-2XL",
84-
"PRO2-XXS",
85-
"PRO2-XS",
86-
"PRO2-S",
87-
"PRO2-M",
88-
"PRO2-L",
89-
"PLAY2-PICO",
90-
"PLAY2-NANO",
91-
"PLAY2-MICRO",
92-
"GPU-3070-S",
93-
},
9465
ValidateFunc: func(argSpec *core.ArgSpec, value interface{}) error {
9566
// Allow all commercial types
9667
return nil
9768
},
69+
AutoCompleteFunc: completeServerType,
9870
},
9971
{
10072
Name: "name",
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package instance
2+
3+
import (
4+
"context"
5+
"strings"
6+
7+
"github.com/scaleway/scaleway-cli/v2/internal/core"
8+
)
9+
10+
var serverTypes = []string{
11+
"GP1-XS",
12+
"GP1-S",
13+
"GP1-M",
14+
"GP1-L",
15+
"GP1-XL",
16+
17+
"DEV1-S",
18+
"DEV1-M",
19+
"DEV1-L",
20+
"DEV1-XL",
21+
22+
"ENT1-XXS",
23+
"ENT1-XS",
24+
"ENT1-S",
25+
"ENT1-M",
26+
"ENT1-L",
27+
"ENT1-XL",
28+
"ENT1-2XL",
29+
30+
"RENDER-S",
31+
32+
"STARDUST1-S",
33+
34+
"GPU-3070-S",
35+
36+
"PRO2-XXS",
37+
"PRO2-XS",
38+
"PRO2-S",
39+
"PRO2-M",
40+
"PRO2-L",
41+
42+
"PLAY2-PICO",
43+
"PLAY2-NANO",
44+
"PLAY2-MICRO",
45+
46+
"POP2-2C-8G",
47+
"POP2-4C-16G",
48+
"POP2-8C-32G",
49+
"POP2-16C-64G",
50+
"POP2-32C-128G",
51+
"POP2-64C-256G",
52+
53+
"POP2-HM-2C-16G",
54+
"POP2-HM-4C-32G",
55+
"POP2-HM-8C-64G",
56+
"POP2-HM-16C-128G",
57+
"POP2-HM-32C-256G",
58+
"POP2-HM-64C-512G",
59+
60+
"POP2-HC-2C-4G",
61+
"POP2-HC-4C-8G",
62+
"POP2-HC-8C-16G",
63+
"POP2-HC-16C-32G",
64+
"POP2-HC-32C-63G",
65+
"POP2-HC-64C-128G",
66+
}
67+
68+
func completeServerType(_ context.Context, prefix string) core.AutocompleteSuggestions {
69+
suggestions := []string(nil)
70+
71+
for _, serverType := range serverTypes {
72+
if strings.HasPrefix(serverType, prefix) {
73+
suggestions = append(suggestions, serverType)
74+
}
75+
}
76+
77+
return suggestions
78+
}

0 commit comments

Comments
 (0)