Skip to content
Merged
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
20 changes: 20 additions & 0 deletions cmd/scw/testdata/test-all-usage-fip-mac-move-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Move a Virtual MAC from a given Flexible IP onto another Flexible IP.

USAGE:
scw fip mac move [arg=value ...]

ARGS:
fip-id
[dst-fip-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 | nl-ams-1)

FLAGS:
-h, --help help for move

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-fip-mac-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AVAILABLE COMMANDS:
create Generate a virtual MAC on a given Flexible IP
delete Remove a virtual MAC from a Flexible IP
duplicate Duplicate a Virtual MAC
move Move a virtual MAC

FLAGS:
-h, --help help for mac
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Overwrite users and applications configuration in a group. Any information that you add using this command will overwrite the previous configuration.

USAGE:
scw iam group set-members [arg=value ...]

ARGS:
group-id
user-ids.{index}
application-ids.{index}

FLAGS:
-h, --help help for set-members

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use

SEE ALSO:
# Remove a group member
scw iam group remove-member

# Create a group
scw iam group create
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iam-group-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AVAILABLE COMMANDS:
get Get a group
list List groups
remove-member Remove a user or an application from a group
set-members Overwrite users and applications of a group
update Update a group

FLAGS:
Expand Down
18 changes: 18 additions & 0 deletions cmd/scw/testdata/test-all-usage-iam-policy-clone-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Clone a policy. You must define specify the `policy_id` parameter in your request.

USAGE:
scw iam policy clone [arg=value ...]

ARGS:
policy-id

FLAGS:
-h, --help help for clone

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iam-policy-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ USAGE:
scw iam policy <command>

AVAILABLE COMMANDS:
clone Clone a policy
create Create a new policy
delete Delete a policy
get Get an existing policy
Expand Down
22 changes: 22 additions & 0 deletions docs/commands/fip.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Flexible IP API.
- [Generate a virtual MAC on a given Flexible IP](#generate-a-virtual-mac-on-a-given-flexible-ip)
- [Remove a virtual MAC from a Flexible IP](#remove-a-virtual-mac-from-a-flexible-ip)
- [Duplicate a Virtual MAC](#duplicate-a-virtual-mac)
- [Move a virtual MAC](#move-a-virtual-mac)


## Flexible IP management commands
Expand Down Expand Up @@ -244,3 +245,24 @@ scw fip mac duplicate [arg=value ...]



### Move a virtual MAC

Move a Virtual MAC from a given Flexible IP onto another Flexible IP.

**Usage:**

```
scw fip mac move [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| fip-id | Required | |
| dst-fip-id | | |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |



42 changes: 42 additions & 0 deletions docs/commands/iam.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ IAM API.
- [Get a group](#get-a-group)
- [List groups](#list-groups)
- [Remove a user or an application from a group](#remove-a-user-or-an-application-from-a-group)
- [Overwrite users and applications of a group](#overwrite-users-and-applications-of-a-group)
- [Update a group](#update-a-group)
- [JWTs management commands](#jwts-management-commands)
- [Delete a JWT](#delete-a-jwt)
Expand All @@ -29,6 +30,7 @@ IAM API.
- [Permission sets management commands](#permission-sets-management-commands)
- [List permission sets](#list-permission-sets)
- [Policies management commands](#policies-management-commands)
- [Clone a policy](#clone-a-policy)
- [Create a new policy](#create-a-new-policy)
- [Delete a policy](#delete-a-policy)
- [Get an existing policy](#get-an-existing-policy)
Expand Down Expand Up @@ -433,6 +435,27 @@ scw iam group remove-member <group-id ...> [arg=value ...]



### Overwrite users and applications of a group

Overwrite users and applications configuration in a group. Any information that you add using this command will overwrite the previous configuration.

**Usage:**

```
scw iam group set-members [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| group-id | Required | |
| user-ids.{index} | Required | |
| application-ids.{index} | Required | |



### Update a group

Update the parameters of group, including `name` and `description`.
Expand Down Expand Up @@ -548,6 +571,25 @@ scw iam permission-set list [arg=value ...]
Policies management commands.


### Clone a policy

Clone a policy. You must define specify the `policy_id` parameter in your request.

**Usage:**

```
scw iam policy clone [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| policy-id | Required | |



### Create a new policy

Create a new application. You must define the `name` parameter in the request. You can specify parameters such as `user_id`, `groups_id`, `application_id`, `no_principal`, `rules` and its child attributes.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/moby/buildkit v0.11.4
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11 h1:tZBnGI0NIyTUV9+UYQrTFw1gqIcY/TcUBCfLrC/IvKY=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689 h1:QPpApIAOwB3/9ZPu+SOu5bjoN7keDalTCpyCf2VYx4w=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
Expand Down
80 changes: 80 additions & 0 deletions internal/namespaces/iam/v1alpha1/iam_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func GetGeneratedCommands() *core.Commands {
iamGroupCreate(),
iamGroupGet(),
iamGroupUpdate(),
iamGroupSetMembers(),
iamGroupAddMember(),
iamGroupRemoveMember(),
iamGroupDelete(),
Expand All @@ -54,6 +55,7 @@ func GetGeneratedCommands() *core.Commands {
iamPolicyGet(),
iamPolicyUpdate(),
iamPolicyDelete(),
iamPolicyClone(),
iamRuleUpdate(),
iamRuleList(),
iamPermissionSetList(),
Expand Down Expand Up @@ -953,6 +955,56 @@ func iamGroupUpdate() *core.Command {
}
}

func iamGroupSetMembers() *core.Command {
return &core.Command{
Short: `Overwrite users and applications of a group`,
Long: `Overwrite users and applications configuration in a group. Any information that you add using this command will overwrite the previous configuration.`,
Namespace: "iam",
Resource: "group",
Verb: "set-members",
// Deprecated: false,
ArgsType: reflect.TypeOf(iam.SetGroupMembersRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "group-id",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "user-ids.{index}",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "application-ids.{index}",
Required: true,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iam.SetGroupMembersRequest)

client := core.ExtractClient(ctx)
api := iam.NewAPI(client)
return api.SetGroupMembers(request)

},
SeeAlsos: []*core.SeeAlso{
{
Command: "scw iam group remove-member",
Short: "Remove a group member",
},
{
Command: "scw iam group create",
Short: "Create a group",
},
},
}
}

func iamGroupAddMember() *core.Command {
return &core.Command{
Short: `Add a user or an application to a group`,
Expand Down Expand Up @@ -1413,6 +1465,34 @@ func iamPolicyDelete() *core.Command {
}
}

func iamPolicyClone() *core.Command {
return &core.Command{
Short: `Clone a policy`,
Long: `Clone a policy. You must define specify the ` + "`" + `policy_id` + "`" + ` parameter in your request.`,
Namespace: "iam",
Resource: "policy",
Verb: "clone",
// Deprecated: false,
ArgsType: reflect.TypeOf(iam.ClonePolicyRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "policy-id",
Required: true,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iam.ClonePolicyRequest)

client := core.ExtractClient(ctx)
api := iam.NewAPI(client)
return api.ClonePolicy(request)

},
}
}

func iamRuleUpdate() *core.Command {
return &core.Command{
Short: `Set rules of a given policy`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ ID NAME STATUS VERSION NODE TYPE MIN
"required_claim": []
},
"apiserver_cert_sans": [],
"private_network_id": null,
"pools": [
{
"id": "42b228cf-ad4b-458e-b69b-046f8aa3c10c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ GroupsPrefix -
"groups_prefix": "",
"required_claim": []
},
"apiserver_cert_sans": []
"apiserver_cert_sans": [],
"private_network_id": null
}