Skip to content

Commit 12b32fb

Browse files
authored
Merge branch 'master' into v1.6469.0
2 parents 3608de0 + 776269a commit 12b32fb

File tree

10 files changed

+192
-10
lines changed

10 files changed

+192
-10
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
This command opens the current settings of your RDB instance in your $EDITOR.
4+
You can modify the values and save the file to apply the new configuration.
5+
6+
USAGE:
7+
scw rdb setting edit <instance-id ...> [arg=value ...]
8+
9+
EXAMPLES:
10+
Edit instance settings in YAML
11+
scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml
12+
13+
Edit instance settings in JSON
14+
scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json
15+
16+
ARGS:
17+
instance-id ID of the instance
18+
[mode=yaml] marshaling used when editing data (yaml | json)
19+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
20+
21+
FLAGS:
22+
-h, --help help for edit
23+
24+
GLOBAL FLAGS:
25+
-c, --config string The path to the config file
26+
-D, --debug Enable debug mode
27+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
28+
-p, --profile string The config profile to use

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ USAGE:
1212
AVAILABLE COMMANDS:
1313
add Add Database Instance advanced settings
1414
delete Delete Database Instance advanced settings
15+
edit Edit Database Instance settings in your default editor
1516
set Set Database Instance advanced settings
1617

1718
FLAGS:

docs/commands/rdb.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL.
6666
- [Setting management](#setting-management)
6767
- [Add Database Instance advanced settings](#add-database-instance-advanced-settings)
6868
- [Delete Database Instance advanced settings](#delete-database-instance-advanced-settings)
69+
- [Edit Database Instance settings in your default editor](#edit-database-instance-settings-in-your-default-editor)
6970
- [Set Database Instance advanced settings](#set-database-instance-advanced-settings)
7071
- [Block snapshot management](#block-snapshot-management)
7172
- [Create a Database Instance snapshot](#create-a-database-instance-snapshot)
@@ -1398,6 +1399,43 @@ scw rdb setting delete [arg=value ...]
13981399

13991400

14001401

1402+
### Edit Database Instance settings in your default editor
1403+
1404+
This command opens the current settings of your RDB instance in your $EDITOR.
1405+
You can modify the values and save the file to apply the new configuration.
1406+
1407+
**Usage:**
1408+
1409+
```
1410+
scw rdb setting edit <instance-id ...> [arg=value ...]
1411+
```
1412+
1413+
1414+
**Args:**
1415+
1416+
| Name | | Description |
1417+
|------|---|-------------|
1418+
| instance-id | Required | ID of the instance |
1419+
| mode | Default: `yaml`<br />One of: `yaml`, `json` | marshaling used when editing data |
1420+
| 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 |
1421+
1422+
1423+
**Examples:**
1424+
1425+
1426+
Edit instance settings in YAML
1427+
```
1428+
scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml
1429+
```
1430+
1431+
Edit instance settings in JSON
1432+
```
1433+
scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json
1434+
```
1435+
1436+
1437+
1438+
14011439
### Set Database Instance advanced settings
14021440

14031441
Update an advanced setting for a Database Instance. Settings added upon database engine initialization can only be defined once, and cannot, therefore, be updated.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.13.2
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250502134911-8e9702aa2a77
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250425155221-30ae936d86f6
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.9.1
2929
github.com/spf13/pflag v1.0.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
466466
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
467467
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
468468
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
469-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250502134911-8e9702aa2a77 h1:PrRutFdLjGTw4ULbymArBYDEuxk/n2BWy0mGKwCe4Fk=
470-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250502134911-8e9702aa2a77/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
469+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250425155221-30ae936d86f6 h1:8gDJ72j/by4RH6VDkW9lTPpdve5v7Ou2ypD4ZbGzYvY=
470+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250425155221-30ae936d86f6/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
471471
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
472472
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
473473
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

internal/namespaces/container/v1beta1/container_cli.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func containerNamespaceCreate() *core.Command {
272272
},
273273
{
274274
Name: "tags.{index}",
275-
Short: `[ALPHA] Tags of the Serverless Container Namespace`,
275+
Short: `Tags of the Serverless Container Namespace`,
276276
Required: false,
277277
Deprecated: false,
278278
Positional: false,
@@ -339,7 +339,7 @@ func containerNamespaceUpdate() *core.Command {
339339
},
340340
{
341341
Name: "tags.{index}",
342-
Short: `[ALPHA] Tags of the Serverless Container Namespace`,
342+
Short: `Tags of the Serverless Container Namespace`,
343343
Required: false,
344344
Deprecated: false,
345345
Positional: false,
@@ -708,6 +708,13 @@ func containerContainerCreate() *core.Command {
708708
Deprecated: false,
709709
Positional: false,
710710
},
711+
{
712+
Name: "tags.{index}",
713+
Short: `Tags of the Serverless Container`,
714+
Required: false,
715+
Deprecated: false,
716+
Positional: false,
717+
},
711718
core.RegionArgSpec(
712719
scw.RegionFrPar,
713720
scw.RegionNlAms,
@@ -923,6 +930,13 @@ func containerContainerUpdate() *core.Command {
923930
Deprecated: false,
924931
Positional: false,
925932
},
933+
{
934+
Name: "tags.{index}",
935+
Short: `Tags of the Serverless Container`,
936+
Required: false,
937+
Deprecated: false,
938+
Positional: false,
939+
},
926940
core.RegionArgSpec(
927941
scw.RegionFrPar,
928942
scw.RegionNlAms,

internal/namespaces/file/v1alpha1/file_cli.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ func fileFilesystemDelete() *core.Command {
310310

311311
func fileFilesystemUpdate() *core.Command {
312312
return &core.Command{
313-
Short: `Update filesystem properties`,
314-
Long: `Update the technical details of a filesystem, such as its name, tags or its new size.
315-
You can only resize a filesystem to a larger size.`,
313+
Short: `Update filesystem properties`,
314+
Long: `Update the technical details of a filesystem, such as its name, tags or its new size.`,
316315
Namespace: "file",
317316
Resource: "filesystem",
318317
Verb: "update",

internal/namespaces/function/v1beta1/function_cli.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func functionNamespaceCreate() *core.Command {
319319
},
320320
{
321321
Name: "tags.{index}",
322-
Short: `[ALPHA] Tags of the Serverless Function Namespace`,
322+
Short: `Tags of the Serverless Function Namespace`,
323323
Required: false,
324324
Deprecated: false,
325325
Positional: false,
@@ -386,7 +386,7 @@ func functionNamespaceUpdate() *core.Command {
386386
},
387387
{
388388
Name: "tags.{index}",
389-
Short: `[ALPHA] Tags of the Serverless Function Namespace`,
389+
Short: `Tags of the Serverless Function Namespace`,
390390
Required: false,
391391
Deprecated: false,
392392
Positional: false,
@@ -721,6 +721,13 @@ func functionFunctionCreate() *core.Command {
721721
"v2",
722722
},
723723
},
724+
{
725+
Name: "tags.{index}",
726+
Short: `Tags of the Serverless Function`,
727+
Required: false,
728+
Deprecated: false,
729+
Positional: false,
730+
},
724731
core.RegionArgSpec(
725732
scw.RegionFrPar,
726733
scw.RegionNlAms,
@@ -903,6 +910,13 @@ func functionFunctionUpdate() *core.Command {
903910
"v2",
904911
},
905912
},
913+
{
914+
Name: "tags.{index}",
915+
Short: `Tags of the Serverless Function`,
916+
Required: false,
917+
Deprecated: false,
918+
Positional: false,
919+
},
906920
core.RegionArgSpec(
907921
scw.RegionFrPar,
908922
scw.RegionNlAms,

internal/namespaces/rdb/v1/custom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func GetCommands() *core.Commands {
4949
instanceConnectCommand(),
5050
instanceWaitCommand(),
5151
userGetURLCommand(),
52+
instanceEditSettingsCommand(),
5253
))
5354
cmds.MustFind("rdb", "acl", "add").Override(aclAddBuilder)
5455
cmds.MustFind("rdb", "acl", "delete").Override(aclDeleteBuilder)

internal/namespaces/rdb/v1/custom_instance.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/fatih/color"
1818
"github.com/scaleway/scaleway-cli/v2/core"
1919
"github.com/scaleway/scaleway-cli/v2/core/human"
20+
"github.com/scaleway/scaleway-cli/v2/internal/editor"
2021
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
2122
"github.com/scaleway/scaleway-cli/v2/internal/passwordgenerator"
2223
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
@@ -925,3 +926,89 @@ func instanceConnectCommand() *core.Command {
925926
},
926927
}
927928
}
929+
930+
func instanceEditSettingsCommand() *core.Command {
931+
type editSettingsArgs struct {
932+
InstanceID string `arg:"positional,required"`
933+
Region scw.Region `arg:"required"`
934+
Mode editor.MarshalMode
935+
}
936+
937+
return &core.Command{
938+
Namespace: "rdb",
939+
Resource: "setting",
940+
Verb: "edit",
941+
Short: "Edit Database Instance settings in your default editor",
942+
Long: `This command opens the current settings of your RDB instance in your $EDITOR.
943+
You can modify the values and save the file to apply the new configuration.`,
944+
ArgsType: reflect.TypeOf(editSettingsArgs{}),
945+
ArgSpecs: core.ArgSpecs{
946+
{
947+
Name: "instance-id",
948+
Short: "ID of the instance",
949+
Required: true,
950+
Positional: true,
951+
},
952+
editor.MarshalModeArgSpec(), // --mode=yaml|json
953+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
954+
},
955+
Examples: []*core.Example{
956+
{
957+
Short: "Edit instance settings in YAML",
958+
Raw: "scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml",
959+
},
960+
{
961+
Short: "Edit instance settings in JSON",
962+
Raw: "scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json",
963+
},
964+
},
965+
Run: func(ctx context.Context, argsI interface{}) (interface{}, error) {
966+
args := argsI.(*editSettingsArgs)
967+
968+
client := core.ExtractClient(ctx)
969+
api := rdbSDK.NewAPI(client)
970+
971+
instance, err := api.GetInstance(&rdbSDK.GetInstanceRequest{
972+
InstanceID: args.InstanceID,
973+
Region: args.Region,
974+
})
975+
if err != nil {
976+
return nil, err
977+
}
978+
979+
initialRequest := &rdbSDK.SetInstanceSettingsRequest{
980+
Region: args.Region,
981+
InstanceID: args.InstanceID,
982+
Settings: instance.Settings,
983+
}
984+
985+
editedRequestRaw, err := editor.UpdateResourceEditor(
986+
initialRequest,
987+
&rdbSDK.SetInstanceSettingsRequest{
988+
Region: args.Region,
989+
InstanceID: args.InstanceID,
990+
},
991+
&editor.Config{
992+
PutRequest: true,
993+
MarshalMode: args.Mode,
994+
},
995+
)
996+
if err != nil {
997+
return nil, err
998+
}
999+
1000+
editedRequest := editedRequestRaw.(*rdbSDK.SetInstanceSettingsRequest)
1001+
1002+
if reflect.DeepEqual(initialRequest.Settings, editedRequest.Settings) {
1003+
return &core.SuccessResult{Message: "No changes detected."}, nil
1004+
}
1005+
1006+
_, err = api.SetInstanceSettings(editedRequest)
1007+
if err != nil {
1008+
return nil, err
1009+
}
1010+
1011+
return &core.SuccessResult{Message: "Settings successfully updated."}, nil
1012+
},
1013+
}
1014+
}

0 commit comments

Comments
 (0)