Skip to content
Closed
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
@@ -1,37 +1,16 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Create a new placement group in a specified Availability Zone.
Create a new placement group.

USAGE:
scw instance placement-group create [arg=value ...]

EXAMPLES:
Create a placement group with default name
scw instance placement-group create

Create a placement group with the specified name
scw instance placement-group create name=foobar

Create an enforced placement group
scw instance placement-group create policy-mode=enforced

Create an optional placement group
scw instance placement-group create policy-mode=optional

Create an optional low latency placement group
scw instance placement-group create policy-mode=optional policy-type=low_latency

Create an enforced low latency placement group
scw instance placement-group create policy-mode=enforced policy-type=low_latency

ARGS:
[name=<generated>] Name of the placement group
[project-id] Project ID to use. If none is passed the default project ID will be used
[tags.{index}] Tags of the placement group
[policy-mode] Operating mode of the placement group (optional | enforced)
[policy-type] Policy type of the placement group (max_availability | low_latency)
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)
[project-id] Project ID to use. If none is passed the default project ID will be used
[name=<generated>] Name of the placement group
[policy-type=max_availability] Policy type of the placement group (unknown_policy_type | low_latency | max_availability)
[tags.{index}] Tags of the placement group
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)

FLAGS:
-h, --help help for create
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Delete the specified placement group.
Delete a specified placement group.

USAGE:
scw instance placement-group delete <placement-group-id ...> [arg=value ...]

EXAMPLES:
Delete a placement group in the default zone with the specified ID
scw instance placement-group delete 11111111-1111-1111-1111-111111111111

Delete a placement group in fr-par-1 zone with the specified ID
scw instance placement-group delete 11111111-1111-1111-1111-111111111111 zone=fr-par-1

ARGS:
placement-group-id UUID of the placement group you want to delete
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Command "get-servers" is deprecated, it is not available in v2 of the API and will be removed when v1 reaches end of support.
Get all Instances belonging to the specified placement group.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Get the specified placement group.
Get a specified placement group.

USAGE:
scw instance placement-group get <placement-group-id ...> [arg=value ...]

EXAMPLES:
Get a placement group with the specified ID
scw instance placement-group get 6c15f411-3b6f-402d-8eba-ae24ef9254e9

ARGS:
placement-group-id UUID of the placement group you want to get
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)
placement-group-id UUID of the placement group you want to get
[list-servers=true] Whether to list the servers in the Placement Group or not.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)

FLAGS:
-h, --help help for get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
List all placement groups in a specified Availability Zone.
List all placement groups.

USAGE:
scw instance placement-group list [arg=value ...]

EXAMPLES:
List all placement groups in the default zone
scw instance placement-group list

List placement groups that match a specified name ('cluster1' will return 'cluster100' and 'cluster1' but not 'foo')
scw instance placement-group list name=cluster1

ARGS:
[project-id] List only placement groups of this Project ID
[tags] List placement groups with these exact tags (to filter with several tags, use commas to separate them)
[name] Filter placement groups by name (for eg. "cluster1" will return "cluster100" and "cluster1" but not "foo")
[organization-id] List only placement groups of this Organization ID
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1 | all)
[page-token] The initial pagination token to start from
[page-size] The maximum number of placement groups to return
[order-by] The field by which to order the result list (created_at_desc | created_at_asc | updated_at_desc | updated_at_asc)
[project-id] Project ID to use. If none is passed the default project ID will be used
[placement-group-ids.{index}] List only placement groups with these IDs
[name] Filter placement groups by name
[tags.{index}] List placement groups with these exact tags
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)

FLAGS:
-h, --help help for list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Command "set-servers" is deprecated, it is not available in v2 of the API and will be removed when v1 reaches end of support.
Set all Instances belonging to the specified placement group.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Command "set" is deprecated, it is not available in v2 of the API and will be removed when v1 reaches end of support.
Set all parameters of the specified placement group.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Command "update-servers" is deprecated, it is not available in v2 of the API and will be removed when v1 reaches end of support.
Update all Instances belonging to the specified placement group.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Update one or more parameter of the specified placement group.
Update the properties of a specified placement group.

USAGE:
scw instance placement-group update <placement-group-id ...> [arg=value ...]

EXAMPLES:
Update the name of a placement group
scw instance placement-group update 95053f33-cd3c-4cdc-b2b0-57d2dda97b13 name=foobar

Update the policy mode of a placement group (all Instances in your placement group MUST be shut down)
scw instance placement-group update 1f883434-8c2d-40f0-b686-d0754b3a7bc0 policy-mode=enforced

Update the policy type of a placement group (all Instances in your placement group MUST be shutdown)
scw instance placement-group update 0954ec26-9917-47b6-8c5c-7bc81d7bb9d2 policy-type=low_latency

ARGS:
placement-group-id UUID of the placement group
[name] Name of the placement group
[policy-type] Policy type of the placement group (unknown_policy_type | low_latency | max_availability)
[tags.{index}] Tags of the placement group
[policy-mode] Operating mode of the placement group (optional | enforced)
[policy-type] Policy type of the placement group (max_availability | low_latency)
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3 | it-mil-1)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Placement groups allow the user to express a preference regarding
the physical position of a group of Instances. The feature lets the user
choose to either group Instances on the same physical hardware for
best network throughput and low latency or to spread Instances across
best network throughput and low latency, or spread Instances across
physically distanced hardware to reduce the risk of physical failure.

The operating mode is selected by a `policy_type`. Two policy
Expand All @@ -13,25 +13,19 @@ types are available:

The `policy_type` is set to `max_availability` by default.

For each policy types, one of the two `policy_mode` may be selected:
- `optional` will start your Instances even if the constraint is not respected
- `enforced` guarantees that if the Instance starts, the constraint is respected

The `policy_mode` is set by default to `optional`.

USAGE:
scw instance placement-group <command>

AVAILABLE COMMANDS:
create Create a placement group
delete Delete the specified placement group
delete Delete a placement group
get Get a placement group
get-servers Get placement group servers
list List placement groups
set Set placement group
set-servers Set placement group servers
update Update a placement group
update-servers Update placement group servers
get-servers Get placement group servers (Deprecated)
set Set placement group (Deprecated)
set-servers Set placement group servers (Deprecated)
update-servers Update placement group servers (Deprecated)

FLAGS:
-h, --help help for placement-group
Expand Down
21 changes: 19 additions & 2 deletions core/cobra_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ func (b *cobraBuilder) build() *cobra.Command {
}

// If Resource is empty, the command represent a namespace directly.
// Prefer this command for namespace metadata, but only set it once (first root command wins).
if cmd.Resource == "" {
existing := commandsIndex[cmd.Namespace]
// Only update if the existing command is not already a root command
if existing.Resource != "" {
commandsIndex[cmd.Namespace] = cmd
}

continue
}

Expand All @@ -76,7 +83,14 @@ func (b *cobraBuilder) build() *cobra.Command {
index[cmd.Namespace].AddCommand(cobraCmd)
}

// Prefer commands with no verb for the resource metadata (parent resource command).
// Only update if the existing command is not already a parent resource command.
if cmd.Verb == "" {
existing := commandsIndex[resourceKey]
if existing.Verb != "" {
commandsIndex[resourceKey] = cmd
}

continue
}

Expand Down Expand Up @@ -211,8 +225,11 @@ func (b *cobraBuilder) hydrateCobra(
}

if cmd.Deprecated {
cobraCmd.IsAvailableCommand()
cobraCmd.Deprecated = "Deprecated:"
cobraCmd.Deprecated = cmd.DeprecationMessage
if cobraCmd.Deprecated == "" {
// String length has to be > 0 for Cobra to flag the command as deprecated
cobraCmd.Deprecated = " "
}
}

if commandHasWeb(cmd) {
Expand Down
6 changes: 5 additions & 1 deletion core/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ type Command struct {

// Groups contains a list of groups IDs
Groups []string
//

// Deprecation
// Whether the command is deprecated
Deprecated bool
// The deprecation message to be displayed. Cobra will write it after 'Command "x" is deprecated, '
DeprecationMessage string

// ExcludeFromMCP will exclude the command from the MCP server (scw mcp server)
ExcludeFromMCP bool
Expand Down
Loading
Loading