Skip to content

Commit 9e5955a

Browse files
authored
Merge pull request #63 from serverscom/feature-set-rename
Feature set rename state to command
2 parents 7427092 + c6bb07c commit 9e5955a

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

cmd/entities/hosts/features.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func newListEBMFeaturesCmd(cmdContext *base.CmdContext) *cobra.Command {
2626

2727
type featureSetFlags struct {
2828
Feature string
29-
State string
29+
Command string
3030
IPXEConfig string
3131
AuthMethod []string
3232
SSHKeyFingerprint []string
@@ -53,13 +53,13 @@ func newEBMFeatureSetCmd(cmdContext *base.CmdContext) *cobra.Command {
5353
err error
5454
)
5555

56-
switch flags.State {
56+
switch flags.Command {
5757
case "activate":
5858
result, err = activateEBMFeature(ctx, scClient, id, flags)
5959
case "deactivate":
6060
result, err = deactivateEBMFeature(ctx, scClient, id, flags.Feature)
6161
default:
62-
return fmt.Errorf("invalid state %q: must be activate or deactivate", flags.State)
62+
return fmt.Errorf("invalid command %q: must be activate or deactivate", flags.Command)
6363
}
6464

6565
if err != nil {
@@ -76,13 +76,13 @@ func newEBMFeatureSetCmd(cmdContext *base.CmdContext) *cobra.Command {
7676
}
7777

7878
cmd.Flags().StringVar(&flags.Feature, "feature", "", "feature name (required)")
79-
cmd.Flags().StringVar(&flags.State, "state", "", "desired state: activate or deactivate (required)")
79+
cmd.Flags().StringVar(&flags.Command, "command", "", "command to run: activate or deactivate (required)")
8080
cmd.Flags().StringVar(&flags.IPXEConfig, "ipxe-config", "", "iPXE config script (for private_ipxe_boot)")
8181
cmd.Flags().StringArrayVar(&flags.AuthMethod, "auth-method", nil, "auth method: password, ssh_key (for host_rescue_mode)")
8282
cmd.Flags().StringArrayVar(&flags.SSHKeyFingerprint, "ssh-key-fingerprint", nil, "SSH key fingerprint (for host_rescue_mode with ssh_key auth)")
8383

8484
_ = cmd.MarkFlagRequired("feature")
85-
_ = cmd.MarkFlagRequired("state")
85+
_ = cmd.MarkFlagRequired("command")
8686

8787
return cmd
8888
}

cmd/entities/hosts/features_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
162162
}{
163163
{
164164
name: "activate feature",
165-
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--state", "activate", "--output", "json"},
165+
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--command", "activate", "--output", "json"},
166166
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set.json")),
167167
configureMock: func(mock *mocks.MockHostsService) {
168168
mock.EXPECT().
@@ -172,7 +172,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
172172
},
173173
{
174174
name: "deactivate feature",
175-
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--state", "deactivate", "--output", "json"},
175+
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--command", "deactivate", "--output", "json"},
176176
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set.json")),
177177
configureMock: func(mock *mocks.MockHostsService) {
178178
mock.EXPECT().
@@ -182,7 +182,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
182182
},
183183
{
184184
name: "activate private_ipxe_boot with ipxe-config",
185-
args: []string{testServerID, "--feature", "private_ipxe_boot", "--state", "activate", "--ipxe-config", "#!ipxe\nchain http://boot.example.com", "--output", "json"},
185+
args: []string{testServerID, "--feature", "private_ipxe_boot", "--command", "activate", "--ipxe-config", "#!ipxe\nchain http://boot.example.com", "--output", "json"},
186186
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set_private_ipxe_boot.json")),
187187
configureMock: func(mock *mocks.MockHostsService) {
188188
mock.EXPECT().
@@ -194,7 +194,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
194194
},
195195
{
196196
name: "deactivate private_ipxe_boot",
197-
args: []string{testServerID, "--feature", "private_ipxe_boot", "--state", "deactivate", "--output", "json"},
197+
args: []string{testServerID, "--feature", "private_ipxe_boot", "--command", "deactivate", "--output", "json"},
198198
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set_private_ipxe_boot.json")),
199199
configureMock: func(mock *mocks.MockHostsService) {
200200
mock.EXPECT().
@@ -204,7 +204,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
204204
},
205205
{
206206
name: "activate host_rescue_mode with password auth",
207-
args: []string{testServerID, "--feature", "host_rescue_mode", "--state", "activate", "--auth-method", "password", "--output", "json"},
207+
args: []string{testServerID, "--feature", "host_rescue_mode", "--command", "activate", "--auth-method", "password", "--output", "json"},
208208
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set_host_rescue_mode.json")),
209209
configureMock: func(mock *mocks.MockHostsService) {
210210
mock.EXPECT().
@@ -216,7 +216,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
216216
},
217217
{
218218
name: "activate host_rescue_mode with ssh_key auth",
219-
args: []string{testServerID, "--feature", "host_rescue_mode", "--state", "activate", "--auth-method", "ssh_key", "--ssh-key-fingerprint", "aa:bb:cc", "--output", "json"},
219+
args: []string{testServerID, "--feature", "host_rescue_mode", "--command", "activate", "--auth-method", "ssh_key", "--ssh-key-fingerprint", "aa:bb:cc", "--output", "json"},
220220
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set_host_rescue_mode.json")),
221221
configureMock: func(mock *mocks.MockHostsService) {
222222
mock.EXPECT().
@@ -229,7 +229,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
229229
},
230230
{
231231
name: "deactivate host_rescue_mode",
232-
args: []string{testServerID, "--feature", "host_rescue_mode", "--state", "deactivate", "--output", "json"},
232+
args: []string{testServerID, "--feature", "host_rescue_mode", "--command", "deactivate", "--output", "json"},
233233
expectedOutput: testutils.ReadFixture(filepath.Join(featuresFixtureBasePath, "feature_set_host_rescue_mode.json")),
234234
configureMock: func(mock *mocks.MockHostsService) {
235235
mock.EXPECT().
@@ -239,7 +239,7 @@ func TestEBMFeatureSetCmd(t *testing.T) {
239239
},
240240
{
241241
name: "api error",
242-
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--state", "activate"},
242+
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--command", "activate"},
243243
expectError: true,
244244
configureMock: func(mock *mocks.MockHostsService) {
245245
mock.EXPECT().
@@ -248,13 +248,13 @@ func TestEBMFeatureSetCmd(t *testing.T) {
248248
},
249249
},
250250
{
251-
name: "invalid state",
252-
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--state", "invalid"},
251+
name: "invalid command",
252+
args: []string{testServerID, "--feature", "disaggregated_public_ports", "--command", "invalid"},
253253
expectError: true,
254254
},
255255
{
256256
name: "unsupported feature",
257-
args: []string{testServerID, "--feature", "unknown_feature", "--state", "activate"},
257+
args: []string{testServerID, "--feature", "unknown_feature", "--command", "activate"},
258258
expectError: true,
259259
},
260260
}

docs/srvctl-hosts-ebm-feature-set/description.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This command activates or deactivates a feature on the selected enterprise bare metal server.
22

3-
The `--feature` and `--state` flags are required. The `--state` flag accepts `activate` or `deactivate`.
3+
The `--feature` and `--command` flags are required. The `--command` flag accepts `activate` or `deactivate`.
44

55
Supported feature names:
66

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
A command to activate disaggregated public ports on the server with the "ex4mp1eID" ID:
22

33
```
4-
srvctl hosts ebm feature-set ex4mp1eID --feature disaggregated_public_ports --state activate
4+
srvctl hosts ebm feature-set ex4mp1eID --feature disaggregated_public_ports --command activate
55
```
66

77
A command to deactivate disaggregated public ports on the server with the "ex4mp1eID" ID:
88

99
```
10-
srvctl hosts ebm feature-set ex4mp1eID --feature disaggregated_public_ports --state deactivate
10+
srvctl hosts ebm feature-set ex4mp1eID --feature disaggregated_public_ports --command deactivate
1111
```
1212

1313
A command to activate rescue mode with password and SSH key authentication:
1414

1515
```
1616
srvctl hosts ebm feature-set ex4mp1eID \
1717
--feature host_rescue_mode \
18-
--state activate \
18+
--command activate \
1919
--auth-method password \
2020
--auth-method ssh_key \
2121
--ssh-key-fingerprint aa:bb:cc:dd:ee:ff
@@ -26,12 +26,12 @@ A command to activate private iPXE boot with a custom script:
2626
```
2727
srvctl hosts ebm feature-set ex4mp1eID \
2828
--feature private_ipxe_boot \
29-
--state activate \
29+
--command activate \
3030
--ipxe-config "#!ipxe\nchain http://boot.example.com/script.ipxe"
3131
```
3232

3333
A command to deactivate rescue mode:
3434

3535
```
36-
srvctl hosts ebm feature-set ex4mp1eID --feature host_rescue_mode --state deactivate
36+
srvctl hosts ebm feature-set ex4mp1eID --feature host_rescue_mode --command deactivate
3737
```

0 commit comments

Comments
 (0)