Skip to content

Commit 270b838

Browse files
authored
fix(instance): remove hardcoded offers (#2785)
1 parent 714febb commit 270b838

15 files changed

+1028
-876
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
@@ -36,7 +36,7 @@ EXAMPLES:
3636

3737
ARGS:
3838
image=ubuntu_jammy Image ID or label of the server
39-
type=DEV1-S Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)
39+
type Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)
4040
[name=<generated>] Server name
4141
[root-volume] Local root volume of the server
4242
[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
@@ -1709,7 +1709,7 @@ scw instance server create [arg=value ...]
17091709
| Name | | Description |
17101710
|------|---|-------------|
17111711
| image | Required<br />Default: `ubuntu_jammy` | Image ID or label of the server |
1712-
| type | Required<br />Default: `DEV1-S` | Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/) |
1712+
| type | Required | Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/) |
17131713
| name | Default: `<generated>` | Server name |
17141714
| root-volume | | Local root volume of the server |
17151715
| additional-volumes.{index} | | Additional local and block volumes attached to your server |

internal/namespaces/instance/v1/custom_image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Test_ImageCreate(t *testing.T) {
3232
t.Run("Use additional snapshots", core.Test(&core.TestConfig{
3333
Commands: instance.GetCommands(),
3434
BeforeFunc: core.BeforeFuncCombine(
35-
core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu_focal root-volume=local:10GB additional-volumes.0=local:10GB -w"),
35+
core.ExecStoreBeforeCmd("Server", "scw instance server create type=DEV1-S image=ubuntu_focal root-volume=local:10GB additional-volumes.0=local:10GB -w"),
3636
core.ExecStoreBeforeCmd("SnapshotA", `scw instance snapshot create -w name=cli-test-image-create-snapshotA volume-id={{ (index .Server.Volumes "0").ID }}`),
3737
core.ExecStoreBeforeCmd("SnapshotB", `scw instance snapshot create -w name=cli-test-image-create-snapshotB volume-id={{ (index .Server.Volumes "1").ID }}`),
3838
),

internal/namespaces/instance/v1/custom_ip_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func Test_IPAttach(t *testing.T) {
1111
t.Run("With UUID", core.Test(&core.TestConfig{
1212
Commands: instance.GetCommands(),
1313
BeforeFunc: core.BeforeFuncCombine(
14-
core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true ip=none"),
14+
core.ExecStoreBeforeCmd("Server", "scw instance server create type=DEV1-S stopped=true ip=none"),
1515
createIP("Ip"),
1616
),
1717
Cmd: "scw instance ip attach {{ .Ip.Address }} server-id={{ .Server.ID }}",
@@ -28,7 +28,7 @@ func Test_IPAttach(t *testing.T) {
2828
t.Run("With IP", core.Test(&core.TestConfig{
2929
Commands: instance.GetCommands(),
3030
BeforeFunc: core.BeforeFuncCombine(
31-
core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true ip=none"),
31+
core.ExecStoreBeforeCmd("Server", "scw instance server create type=DEV1-S stopped=true ip=none"),
3232
createIP("Ip"),
3333
),
3434
Cmd: "scw instance ip attach {{ .Ip.Address }} server-id={{ .Server.ID }}",
@@ -47,7 +47,7 @@ func Test_IPDetach(t *testing.T) {
4747
t.Run("With UUID", core.Test(&core.TestConfig{
4848
Commands: instance.GetCommands(),
4949
BeforeFunc: core.BeforeFuncCombine(
50-
core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true ip=none"),
50+
core.ExecStoreBeforeCmd("Server", "scw instance server create type=DEV1-S stopped=true ip=none"),
5151
createIP("Ip"),
5252
core.ExecBeforeCmd("scw instance ip attach {{ .Ip.Address }} server-id={{ .Server.ID }}"),
5353
),
@@ -66,7 +66,7 @@ func Test_IPDetach(t *testing.T) {
6666
t.Run("With IP", core.Test(&core.TestConfig{
6767
Commands: instance.GetCommands(),
6868
BeforeFunc: core.BeforeFuncCombine(
69-
core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true ip=none"),
69+
core.ExecStoreBeforeCmd("Server", "scw instance server create type=DEV1-S stopped=true ip=none"),
7070
createIP("Ip"),
7171
core.ExecBeforeCmd("scw instance ip attach {{ .Ip.Address }} server-id={{ .Server.ID }}"),
7272
),

internal/namespaces/instance/v1/custom_placement_group_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func Test_GetPlacementGroup(t *testing.T) {
1111
t.Run("simple", core.Test(&core.TestConfig{
1212
BeforeFunc: core.BeforeFuncCombine(
1313
core.ExecStoreBeforeCmd("PlacementGroup", "scw instance placement-group create"),
14-
core.ExecStoreBeforeCmd("ServerA", "scw instance server create image=ubuntu_jammy stopped=true placement-group-id={{ .PlacementGroup.PlacementGroup.ID }}"),
14+
core.ExecStoreBeforeCmd("ServerA", "scw instance server create type=DEV1-S image=ubuntu_jammy stopped=true placement-group-id={{ .PlacementGroup.PlacementGroup.ID }}"),
1515
),
1616
Commands: instance.GetCommands(),
1717
Cmd: "scw instance placement-group get {{ .PlacementGroup.PlacementGroup.ID }}",

internal/namespaces/instance/v1/custom_server_action_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func Test_ServerTerminate(t *testing.T) {
1919

2020
t.Run("without IP", core.Test(&core.TestConfig{
2121
Commands: instance.GetCommands(),
22-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu-jammy -w"),
22+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("image=ubuntu-jammy -w")),
2323
Cmd: `scw instance server terminate {{ .Server.ID }}`,
2424
Check: core.TestCheckCombine(
2525
core.TestCheckGolden(),
@@ -40,7 +40,7 @@ func Test_ServerTerminate(t *testing.T) {
4040

4141
t.Run("with IP", core.Test(&core.TestConfig{
4242
Commands: instance.GetCommands(),
43-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu-jammy -w"),
43+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("image=ubuntu-jammy -w")),
4444
Cmd: `scw instance server terminate {{ .Server.ID }} with-ip=true`,
4545
Check: core.TestCheckCombine(
4646
core.TestCheckGolden(),
@@ -61,7 +61,7 @@ func Test_ServerTerminate(t *testing.T) {
6161

6262
t.Run("without block", core.Test(&core.TestConfig{
6363
Commands: instance.GetCommands(),
64-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu-jammy additional-volumes.0=block:10G -w"),
64+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("image=ubuntu-jammy additional-volumes.0=block:10G -w")),
6565
Cmd: `scw instance server terminate {{ .Server.ID }} with-ip=true with-block=false`,
6666
Check: core.TestCheckCombine(
6767
core.TestCheckGolden(),
@@ -76,7 +76,7 @@ func Test_ServerTerminate(t *testing.T) {
7676

7777
t.Run("with block", core.Test(&core.TestConfig{
7878
Commands: instance.GetCommands(),
79-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu-jammy additional-volumes.0=block:10G -w"),
79+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("image=ubuntu-jammy additional-volumes.0=block:10G -w")),
8080
Cmd: `scw instance server terminate {{ .Server.ID }} with-ip=true with-block=true -w`,
8181
Check: core.TestCheckCombine(
8282
core.TestCheckGolden(),
@@ -103,7 +103,7 @@ func Test_ServerTerminate(t *testing.T) {
103103
func Test_ServerBackup(t *testing.T) {
104104
t.Run("simple", core.Test(&core.TestConfig{
105105
Commands: instance.GetCommands(),
106-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true image=ubuntu-jammy"),
106+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("stopped=true image=ubuntu-jammy")),
107107
Cmd: `scw instance server backup {{ .Server.ID }} name=backup`,
108108
Check: core.TestCheckCombine(
109109
core.TestCheckGolden(),
@@ -119,7 +119,7 @@ func Test_ServerBackup(t *testing.T) {
119119
func Test_ServerAction(t *testing.T) {
120120
t.Run("manual poweron", core.Test(&core.TestConfig{
121121
Commands: instance.GetCommands(),
122-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create stopped=true image=ubuntu_jammy"),
122+
BeforeFunc: core.ExecStoreBeforeCmd("Server", testServerCommand("stopped=true image=ubuntu_jammy")),
123123
Cmd: `scw instance server action {{ .Server.ID }} action=poweron --wait`,
124124
Check: core.TestCheckCombine(
125125
core.TestCheckExitCode(0),

internal/namespaces/instance/v1/custom_server_create.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func serverCreateCommand() *core.Command {
6767
{
6868
Name: "type",
6969
Short: "Server commercial type (help: https://www.scaleway.com/en/docs/compute/instances/reference-content/choosing-instance-type/)",
70-
Default: core.DefaultValueSetter("DEV1-S"),
7170
Required: true,
7271
ValidateFunc: func(_ *core.ArgSpec, _ interface{}) error {
7372
// Allow all commercial types

0 commit comments

Comments
 (0)