Skip to content

Commit ff5d094

Browse files
authored
chore: rename 'placement-group' arg to 'placement-group-id' in update server command (#673)
1 parent 1765063 commit ff5d094

6 files changed

+1172
-4
lines changed

internal/namespaces/instance/v1/custom_server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,15 @@ func bootscriptMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, erro
176176
func serverUpdateBuilder(c *core.Command) *core.Command {
177177
type instanceUpdateServerRequestCustom struct {
178178
*instance.UpdateServerRequest
179-
IP *instance.NullableStringValue
179+
IP *instance.NullableStringValue
180+
PlacementGroupID *instance.NullableStringValue
180181
}
181182

182183
IPArgSpec := &core.ArgSpec{
183184
Name: "ip",
184185
Short: `IP that should be attached to the server (use ip=none to remove)`,
185186
}
187+
c.ArgSpecs.GetByName("placement-group").Name = "placement-group-id"
186188

187189
c.ArgsType = reflect.TypeOf(instanceUpdateServerRequestCustom{})
188190

@@ -192,6 +194,7 @@ func serverUpdateBuilder(c *core.Command) *core.Command {
192194
customRequest := argsI.(*instanceUpdateServerRequestCustom)
193195

194196
updateServerRequest := customRequest.UpdateServerRequest
197+
updateServerRequest.PlacementGroup = customRequest.PlacementGroupID
195198

196199
attachIPRequest := (*instance.UpdateIPRequest)(nil)
197200

internal/namespaces/instance/v1/custom_server_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func serverCreateCommand() *core.Command {
9595
},
9696
{
9797
Name: "placement-group-id",
98-
Short: "The security group ID in witch the server has to be created",
98+
Short: "The placement group ID in witch the server has to be created",
9999
},
100100
{
101101
Name: "bootscript-id",

internal/namespaces/instance/v1/custom_server_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,28 @@ func Test_ServerUpdateCustom(t *testing.T) {
7272
return nil
7373
},
7474
}))
75+
76+
t.Run("Update server placement-group-id from server with placement-group-id", core.Test(&core.TestConfig{
77+
Commands: GetCommands(),
78+
BeforeFunc: func(ctx *core.BeforeFuncCtx) error {
79+
ctx.Meta["PlacementGroupResponse"] = ctx.ExecuteCmd("scw instance placement-group create")
80+
ctx.Meta["PlacementGroupResponse2"] = ctx.ExecuteCmd("scw instance placement-group create")
81+
ctx.Meta["Server"] = ctx.ExecuteCmd("scw instance server create stopped=true image=ubuntu-bionic placement-group-id={{ .PlacementGroupResponse.PlacementGroup.ID }}")
82+
return nil
83+
},
84+
Cmd: "scw instance server update server-id={{ .Server.ID }} placement-group-id={{ .PlacementGroupResponse2.PlacementGroup.ID }}",
85+
Check: core.TestCheckCombine(
86+
func(t *testing.T, ctx *core.CheckFuncCtx) {
87+
assert.Equal(t,
88+
ctx.Meta["PlacementGroupResponse2"].(*instance.CreatePlacementGroupResponse).PlacementGroup.ID,
89+
ctx.Result.(*instance.UpdateServerResponse).Server.PlacementGroup.ID)
90+
},
91+
),
92+
AfterFunc: func(ctx *core.AfterFuncCtx) error {
93+
ctx.ExecuteCmd("scw instance server delete server-id={{ .Server.ID }} delete-ip=true delete-volumes=true")
94+
ctx.ExecuteCmd("scw instance server delete placement-group-id={{ .PlacementGroupResponse.PlacementGroup.ID }}")
95+
ctx.ExecuteCmd("scw instance server delete placement-group-id={{ .PlacementGroupResponse2.PlacementGroup.ID }}")
96+
return nil
97+
},
98+
}))
7599
}

internal/namespaces/instance/v1/testdata/test-create-server-usage.stderr.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ARGS:
3333
[ipv6] Enable IPv6
3434
[stopped] Do not start server after its creation
3535
[security-group-id] The security group ID it use for this server
36-
[placement-group-id] The security group ID in witch the server has to be created
36+
[placement-group-id] The placement group ID in witch the server has to be created
3737
[bootscript-id] The bootscript ID to use, if empty the local boot will be used
3838

3939
FLAGS:

0 commit comments

Comments
 (0)