Skip to content

Commit 5404b0c

Browse files
authored
feat(rdb): add endpoints management (#3582)
1 parent 0d910d7 commit 5404b0c

File tree

50 files changed

+16636
-5844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+16636
-5844
lines changed

cmd/scw/testdata/test-all-usage-rdb-endpoint-create-usage.golden

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
Create a new endpoint for a Database Instance. You can add `load_balancer` and `private_network` specifications to the body of the request.
44

55
USAGE:
6-
scw rdb endpoint create [arg=value ...]
6+
scw rdb endpoint create <instance-id ...> [arg=value ...]
77

88
ARGS:
9-
instance-id UUID of the Database Instance you to which you want to add an endpoint
10-
[endpoint-spec.private-network.private-network-id] UUID of the Private Network to be connected to the Database Instance
11-
[endpoint-spec.private-network.service-ip] Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations.
12-
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
9+
instance-id UUID of the Database Instance to which you want to add an endpoint
10+
[private-network.private-network-id] UUID of the Private Network to be connected to the Database Instance
11+
[private-network.service-ip] Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations.
12+
[private-network.enable-ipam=true] Will configure your Private Network endpoint with Scaleway IPAM service if true
13+
[load-balancer=true] Will configure a public Load-Balancer endpoint
14+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
1315

1416
FLAGS:
1517
-h, --help help for create
18+
-w, --wait wait until the endpoint is ready
1619

1720
GLOBAL FLAGS:
1821
-c, --config string The path to the config file

cmd/scw/testdata/test-all-usage-rdb-endpoint-delete-usage.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
Delete the endpoint of a Database Instance. You must specify the `region` and `endpoint_id` parameters of the endpoint you want to delete. Note that might need to update any environment configurations that point to the deleted endpoint.
44

55
USAGE:
6-
scw rdb endpoint delete [arg=value ...]
6+
scw rdb endpoint delete <endpoint-id ...> [arg=value ...]
77

88
ARGS:
9+
instance-id UUID of the Database Instance from which you want to delete an endpoint
910
endpoint-id UUID of the endpoint you want to delete
1011
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
1112

1213
FLAGS:
1314
-h, --help help for delete
15+
-w, --wait wait until the endpoint is ready
1416

1517
GLOBAL FLAGS:
1618
-c, --config string The path to the config file

cmd/scw/testdata/test-all-usage-rdb-endpoint-get-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Retrieve information about a Database Instance endpoint. Full details about the endpoint, like `ip`, `port`, `private_network` and `load_balancer` specifications are returned in the response.
44

55
USAGE:
6-
scw rdb endpoint get [arg=value ...]
6+
scw rdb endpoint get <endpoint-id ...> [arg=value ...]
77

88
ARGS:
99
endpoint-id UUID of the endpoint you want to get
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Lists all public and private endpoints of a Database Instance
4+
5+
USAGE:
6+
scw rdb endpoint list <instance-id ...> [arg=value ...]
7+
8+
ARGS:
9+
instance-id ID of the Database Instance
10+
11+
FLAGS:
12+
-h, --help help for list
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-rdb-endpoint-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ AVAILABLE COMMANDS:
1515
create Create a new Database Instance endpoint
1616
delete Delete a Database Instance endpoint
1717
get Get a Database Instance endpoint
18+
list Lists a Database Instance's endpoints
1819
migrate Migrate an existing instance endpoint to another instance
1920

2021
FLAGS:

docs/commands/rdb.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Managed Database for PostgreSQL and MySQL API
2727
- [Create a new Database Instance endpoint](#create-a-new-database-instance-endpoint)
2828
- [Delete a Database Instance endpoint](#delete-a-database-instance-endpoint)
2929
- [Get a Database Instance endpoint](#get-a-database-instance-endpoint)
30+
- [Lists a Database Instance's endpoints](#lists-a-database-instance's-endpoints)
3031
- [Migrate an existing instance endpoint to another instance](#migrate-an-existing-instance-endpoint-to-another-instance)
3132
- [Database engines commands](#database-engines-commands)
3233
- [List available database engines](#list-available-database-engines)
@@ -520,17 +521,19 @@ Create a new endpoint for a Database Instance. You can add `load_balancer` and `
520521
**Usage:**
521522

522523
```
523-
scw rdb endpoint create [arg=value ...]
524+
scw rdb endpoint create <instance-id ...> [arg=value ...]
524525
```
525526

526527

527528
**Args:**
528529

529530
| Name | | Description |
530531
|------|---|-------------|
531-
| instance-id | Required | UUID of the Database Instance you to which you want to add an endpoint |
532-
| endpoint-spec.private-network.private-network-id | | UUID of the Private Network to be connected to the Database Instance |
533-
| endpoint-spec.private-network.service-ip | | Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. |
532+
| instance-id | Required | UUID of the Database Instance to which you want to add an endpoint |
533+
| private-network.private-network-id | | UUID of the Private Network to be connected to the Database Instance |
534+
| private-network.service-ip | | Endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. |
535+
| private-network.enable-ipam | Default: `true` | Will configure your Private Network endpoint with Scaleway IPAM service if true |
536+
| load-balancer | Default: `true` | Will configure a public Load-Balancer endpoint |
534537
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
535538

536539

@@ -542,14 +545,15 @@ Delete the endpoint of a Database Instance. You must specify the `region` and `e
542545
**Usage:**
543546

544547
```
545-
scw rdb endpoint delete [arg=value ...]
548+
scw rdb endpoint delete <endpoint-id ...> [arg=value ...]
546549
```
547550

548551

549552
**Args:**
550553

551554
| Name | | Description |
552555
|------|---|-------------|
556+
| instance-id | Required | UUID of the Database Instance from which you want to delete an endpoint |
553557
| endpoint-id | Required | UUID of the endpoint you want to delete |
554558
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
555559

@@ -562,7 +566,7 @@ Retrieve information about a Database Instance endpoint. Full details about the
562566
**Usage:**
563567

564568
```
565-
scw rdb endpoint get [arg=value ...]
569+
scw rdb endpoint get <endpoint-id ...> [arg=value ...]
566570
```
567571

568572

@@ -575,6 +579,25 @@ scw rdb endpoint get [arg=value ...]
575579

576580

577581

582+
### Lists a Database Instance's endpoints
583+
584+
Lists all public and private endpoints of a Database Instance
585+
586+
**Usage:**
587+
588+
```
589+
scw rdb endpoint list <instance-id ...> [arg=value ...]
590+
```
591+
592+
593+
**Args:**
594+
595+
| Name | | Description |
596+
|------|---|-------------|
597+
| instance-id | Required | ID of the Database Instance |
598+
599+
600+
578601
### Migrate an existing instance endpoint to another instance
579602

580603
Migrate an existing instance endpoint to another instance.

internal/namespaces/rdb/v1/custom.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func GetCommands() *core.Commands {
1414
human.RegisterMarshalerFunc(backupDownloadResult{}, backupResultMarshallerFunc)
1515
human.RegisterMarshalerFunc(createInstanceResult{}, createInstanceResultMarshalerFunc)
1616
human.RegisterMarshalerFunc(rdbACLCustomResult{}, rdbACLCustomResultMarshalerFunc)
17-
human.RegisterMarshalerFunc(core.MultiResults{}, rdbACLCustomMultiResultMarshalerFunc)
17+
human.RegisterMarshalerFunc(rdbEndpointCustomResult{}, rdbEndpointCustomResultMarshalerFunc)
1818
human.RegisterMarshalerFunc(rdb.DatabaseBackup{}, backupExportDisplayBuilder)
1919

2020
human.RegisterMarshalerFunc(rdb.InstanceStatus(""), human.EnumMarshalFunc(instanceStatusMarshalSpecs))
@@ -24,35 +24,40 @@ func GetCommands() *core.Commands {
2424
human.RegisterMarshalerFunc(rdb.ACLRuleAction(""), human.EnumMarshalFunc(aclRuleActionMarshalSpecs))
2525

2626
cmds.Merge(core.NewCommands(
27-
instanceWaitCommand(),
28-
instanceConnectCommand(),
29-
backupWaitCommand(),
27+
aclEditCommand(),
3028
backupDownloadCommand(),
29+
backupWaitCommand(),
30+
databaseGetURLCommand(),
31+
endpointListCommand(),
3132
engineSettingsCommand(),
32-
aclEditCommand(),
33+
instanceConnectCommand(),
34+
instanceWaitCommand(),
3335
userGetURLCommand(),
34-
databaseGetURLCommand(),
3536
))
3637
cmds.MustFind("rdb", "acl", "add").Override(aclAddBuilder)
3738
cmds.MustFind("rdb", "acl", "delete").Override(aclDeleteBuilder)
3839
cmds.MustFind("rdb", "acl", "set").Override(aclSetBuilder)
3940

4041
cmds.MustFind("rdb", "backup", "create").Override(backupCreateBuilder)
4142
cmds.MustFind("rdb", "backup", "export").Override(backupExportBuilder)
42-
cmds.MustFind("rdb", "backup", "restore").Override(backupRestoreBuilder)
4343
cmds.MustFind("rdb", "backup", "list").Override(backupListBuilder)
44+
cmds.MustFind("rdb", "backup", "restore").Override(backupRestoreBuilder)
45+
46+
cmds.MustFind("rdb", "endpoint", "create").Override(endpointCreateBuilder)
47+
cmds.MustFind("rdb", "endpoint", "delete").Override(endpointDeleteBuilder)
48+
cmds.MustFind("rdb", "endpoint", "get").Override(endpointGetBuilder)
49+
50+
cmds.MustFind("rdb", "engine", "list").Override(engineListBuilder)
4451

4552
cmds.MustFind("rdb", "instance", "create").Override(instanceCreateBuilder)
4653
cmds.MustFind("rdb", "instance", "clone").Override(instanceCloneBuilder)
47-
cmds.MustFind("rdb", "instance", "upgrade").Override(instanceUpgradeBuilder)
48-
cmds.MustFind("rdb", "instance", "update").Override(instanceUpdateBuilder)
49-
cmds.MustFind("rdb", "instance", "get").Override(instanceGetBuilder)
5054
cmds.MustFind("rdb", "instance", "delete").Override(instanceDeleteBuilder)
55+
cmds.MustFind("rdb", "instance", "get").Override(instanceGetBuilder)
56+
cmds.MustFind("rdb", "instance", "update").Override(instanceUpdateBuilder)
57+
cmds.MustFind("rdb", "instance", "upgrade").Override(instanceUpgradeBuilder)
5158

52-
cmds.MustFind("rdb", "engine", "list").Override(engineListBuilder)
53-
54-
cmds.MustFind("rdb", "user", "list").Override(userListBuilder)
5559
cmds.MustFind("rdb", "user", "create").Override(userCreateBuilder)
60+
cmds.MustFind("rdb", "user", "list").Override(userListBuilder)
5661
cmds.MustFind("rdb", "user", "update").Override(userUpdateBuilder)
5762

5863
cmds.MustFind("rdb", "log", "prepare").Override(logPrepareBuilder)

internal/namespaces/rdb/v1/custom_acl.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,6 @@ func rdbACLCustomResultMarshalerFunc(i interface{}, opt *human.MarshalOpt) (stri
4444
return messageStr + "\n" + aclStr, nil
4545
}
4646

47-
func rdbACLCustomMultiResultMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) {
48-
results := i.(core.MultiResults)
49-
switch results[0].(type) {
50-
case *rdbACLCustomResult:
51-
finalMessage := ""
52-
for _, result := range results {
53-
aclResult := result.(*rdbACLCustomResult)
54-
messageStr, err := aclResult.Success.MarshalHuman()
55-
if err != nil {
56-
return "", err
57-
}
58-
finalMessage += messageStr + "\n"
59-
}
60-
61-
aclStr, err := human.Marshal(results[len(results)-1].(*rdbACLCustomResult).Rules, opt)
62-
if err != nil {
63-
return "", err
64-
}
65-
return finalMessage + aclStr, nil
66-
67-
default:
68-
return "", nil
69-
}
70-
}
71-
7247
func aclAddBuilder(c *core.Command) *core.Command {
7348
c.ArgsType = reflect.TypeOf(rdbACLCustomArgs{})
7449
c.ArgSpecs = core.ArgSpecs{

0 commit comments

Comments
 (0)