From c33cfb406b339a11c48c14bb403f443f8d3b62c6 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Thu, 17 Apr 2025 16:08:30 +0200 Subject: [PATCH 01/15] feat(rdb): add command for instance settings --- docs/commands/autocomplete.md | 2 +- docs/commands/rdb.md | 38 ++++++++ internal/namespaces/rdb/v1/custom.go | 1 + internal/namespaces/rdb/v1/custom_instance.go | 90 +++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/docs/commands/autocomplete.md b/docs/commands/autocomplete.md index 95f1777fb1..bb92628259 100644 --- a/docs/commands/autocomplete.md +++ b/docs/commands/autocomplete.md @@ -45,7 +45,7 @@ scw autocomplete script [arg=value ...] | Name | | Description | |------|---|-------------| -| shell | Default: `/bin/bash` | | +| shell | Default: `/bin/zsh` | | | basename | Default: `` | | diff --git a/docs/commands/rdb.md b/docs/commands/rdb.md index 319c25310d..700fc981ef 100644 --- a/docs/commands/rdb.md +++ b/docs/commands/rdb.md @@ -43,6 +43,7 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [List Database Instances](#list-database-instances) - [Renew the TLS certificate of a Database Instance](#renew-the-tls-certificate-of-a-database-instance) - [Restart Database Instance](#restart-database-instance) + - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) - [Update an instance](#update-an-instance) - [Upgrade a Database Instance](#upgrade-a-database-instance) - [Wait for an instance to reach a stable state](#wait-for-an-instance-to-reach-a-stable-state) @@ -919,6 +920,43 @@ scw rdb instance restart [arg=value ...] +### Edit instance settings in your default editor + +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +**Usage:** + +``` +scw rdb instance settings-edit [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| instance-id | Required | ID of the instance | +| mode | Default: `yaml`
One of: `yaml`, `json` | marshaling used when editing data | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + +**Examples:** + + +Edit instance settings in YAML +``` +scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml +``` + +Edit instance settings in JSON +``` +scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json +``` + + + + ### Update an instance Update an instance. diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index 6226f7dc9b..c64a106cfc 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -49,6 +49,7 @@ func GetCommands() *core.Commands { instanceConnectCommand(), instanceWaitCommand(), userGetURLCommand(), + instanceSettingsEditCommand(), )) cmds.MustFind("rdb", "acl", "add").Override(aclAddBuilder) cmds.MustFind("rdb", "acl", "delete").Override(aclDeleteBuilder) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index 1174f9dd60..7cc36a0f6d 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -17,6 +17,7 @@ import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" + "github.com/scaleway/scaleway-cli/v2/internal/editor" "github.com/scaleway/scaleway-cli/v2/internal/interactive" "github.com/scaleway/scaleway-cli/v2/internal/passwordgenerator" "github.com/scaleway/scaleway-cli/v2/internal/terminal" @@ -31,6 +32,12 @@ const ( errorMessageEndpointNotFound = "any endpoint is associated on your instance" ) +type rdbInstanceSettingsEditArgs struct { + Region scw.Region + InstanceID string + Mode editor.MarshalMode +} + var instanceStatusMarshalSpecs = human.EnumMarshalSpecs{ rdbSDK.InstanceStatusUnknown: &human.EnumMarshalSpec{ Attribute: color.Faint, @@ -925,3 +932,86 @@ func instanceConnectCommand() *core.Command { }, } } + +func instanceSettingsEditCommand() *core.Command { + + type settingsEditArgs struct { + InstanceID string `arg:"positional,required"` + Region scw.Region `arg:"required"` + Mode editor.MarshalMode + } + + return &core.Command{ + Namespace: "rdb", + Resource: "instance", + Verb: "settings-edit", + Short: "Edit instance settings in your default editor", + Long: `This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration.`, + ArgsType: reflect.TypeOf(settingsEditArgs{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "instance-id", + Short: "ID of the instance", + Required: true, + Positional: true, + }, + editor.MarshalModeArgSpec(), // --mode=yaml|json + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Examples: []*core.Example{ + { + Short: "Edit instance settings in YAML", + Raw: "scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml", + }, + { + Short: "Edit instance settings in JSON", + Raw: "scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json", + }, + }, + Run: func(ctx context.Context, argsI interface{}) (interface{}, error) { + args := argsI.(*settingsEditArgs) + + client := core.ExtractClient(ctx) + api := rdbSDK.NewAPI(client) + + instance, err := api.GetInstance(&rdbSDK.GetInstanceRequest{ + InstanceID: args.InstanceID, + Region: args.Region, + }) + if err != nil { + return nil, err + } + + initialRequest := &rdbSDK.SetInstanceSettingsRequest{ + Region: args.Region, + InstanceID: args.InstanceID, + Settings: instance.Settings, + } + + editedRequestRaw, err := editor.UpdateResourceEditor(initialRequest, &rdbSDK.SetInstanceSettingsRequest{ + Region: args.Region, + InstanceID: args.InstanceID, + }, &editor.Config{ + PutRequest: true, + MarshalMode: args.Mode, + }) + if err != nil { + return nil, err + } + + editedRequest := editedRequestRaw.(*rdbSDK.SetInstanceSettingsRequest) + + if reflect.DeepEqual(initialRequest.Settings, editedRequest.Settings) { + return &core.SuccessResult{Message: "No changes detected."}, nil + } + + _, err = api.SetInstanceSettings(editedRequest) + if err != nil { + return nil, err + } + + return &core.SuccessResult{Message: "Settings successfully updated."}, nil + }, + } +} From 98b1c51ddb66f5a03874e9477e2e3dea48ce27f9 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Thu, 17 Apr 2025 16:13:11 +0200 Subject: [PATCH 02/15] remove autocomplete.md --- docs/commands/autocomplete.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/commands/autocomplete.md b/docs/commands/autocomplete.md index bb92628259..f3146e73bf 100644 --- a/docs/commands/autocomplete.md +++ b/docs/commands/autocomplete.md @@ -43,10 +43,10 @@ scw autocomplete script [arg=value ...] **Args:** -| Name | | Description | -|------|---|-------------| -| shell | Default: `/bin/zsh` | | -| basename | Default: `` | | +| Name | | Description | +|------|----------------------|-------------| +| shell | Default: `/bin/bash` | | +| basename | Default: `` | | From 7fb1a7cbb89de97a9da6d9c7b4dfdb95968d9518 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Thu, 17 Apr 2025 16:44:07 +0200 Subject: [PATCH 03/15] add golden --- ...ge-rdb-instance-settings-edit-usage.golden | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden new file mode 100644 index 0000000000..fd69e2548b --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden @@ -0,0 +1,28 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +USAGE: + scw rdb instance settings-edit [arg=value ...] + +EXAMPLES: + Edit instance settings in YAML + scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml + + Edit instance settings in JSON + scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json + +ARGS: + instance-id ID of the instance + [mode=yaml] marshaling used when editing data (yaml | json) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for settings-edit + +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 From d68bf055e2ed646df2715113320edb63a480f124 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Thu, 17 Apr 2025 16:56:18 +0200 Subject: [PATCH 04/15] fix lint --- ...ongodb-instance-create-usage.cassette.yaml | 36 +++++++++++++++++++ internal/namespaces/rdb/v1/custom_instance.go | 7 ---- 2 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml diff --git a/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml b/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml new file mode 100644 index 0000000000..dc97b9c177 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml @@ -0,0 +1,36 @@ +--- +version: 1 +interactions: +- request: + body: '{"message":"authentication is denied","method":"api_key","reason":"not_found","type":"denied_authentication"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23 (go1.24.1; darwin; + amd64) cli-e2e-test + url: https://api.scaleway.com/mongodb/v1alpha1/regions/fr-par/versions + method: GET + response: + body: '{"message":"authentication is denied","method":"api_key","reason":"not_found","type":"denied_authentication"}' + headers: + Content-Length: + - "109" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Thu, 17 Apr 2025 14:38:27 GMT + Server: + - Scaleway API Gateway (fr-par-3;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 1fdfe4ef-fffa-4161-bf2f-471785bce599 + status: 401 Unauthorized + code: 401 + duration: "" diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index 7cc36a0f6d..bfadfedd81 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -32,12 +32,6 @@ const ( errorMessageEndpointNotFound = "any endpoint is associated on your instance" ) -type rdbInstanceSettingsEditArgs struct { - Region scw.Region - InstanceID string - Mode editor.MarshalMode -} - var instanceStatusMarshalSpecs = human.EnumMarshalSpecs{ rdbSDK.InstanceStatusUnknown: &human.EnumMarshalSpec{ Attribute: color.Faint, @@ -934,7 +928,6 @@ func instanceConnectCommand() *core.Command { } func instanceSettingsEditCommand() *core.Command { - type settingsEditArgs struct { InstanceID string `arg:"positional,required"` Region scw.Region `arg:"required"` From 1e66c0d0b6411fc0b59d17a1e203a30a51e04b24 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Fri, 18 Apr 2025 14:25:54 +0200 Subject: [PATCH 05/15] fix lint --- .../test-all-usage-rdb-instance-usage.golden | 1 + internal/namespaces/rdb/v1/custom_instance.go | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden index a1665b6816..08d59a3bcf 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden @@ -20,6 +20,7 @@ AVAILABLE COMMANDS: list List Database Instances renew-certificate Renew the TLS certificate of a Database Instance restart Restart Database Instance + settings-edit Edit instance settings in your default editor update Update an instance upgrade Upgrade a Database Instance diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index bfadfedd81..95d37684d9 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -982,13 +982,17 @@ You can modify the values and save the file to apply the new configuration.`, Settings: instance.Settings, } - editedRequestRaw, err := editor.UpdateResourceEditor(initialRequest, &rdbSDK.SetInstanceSettingsRequest{ - Region: args.Region, - InstanceID: args.InstanceID, - }, &editor.Config{ - PutRequest: true, - MarshalMode: args.Mode, - }) + editedRequestRaw, err := editor.UpdateResourceEditor( + initialRequest, + &rdbSDK.SetInstanceSettingsRequest{ + Region: args.Region, + InstanceID: args.InstanceID, + }, + &editor.Config{ + PutRequest: true, + MarshalMode: args.Mode, + }, + ) if err != nil { return nil, err } From 30fe94000280922d07ad1e8b6f403773c4d60712 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Fri, 18 Apr 2025 14:32:04 +0200 Subject: [PATCH 06/15] fix autocomplete.md --- docs/commands/autocomplete.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/commands/autocomplete.md b/docs/commands/autocomplete.md index f3146e73bf..95f1777fb1 100644 --- a/docs/commands/autocomplete.md +++ b/docs/commands/autocomplete.md @@ -43,10 +43,10 @@ scw autocomplete script [arg=value ...] **Args:** -| Name | | Description | -|------|----------------------|-------------| +| Name | | Description | +|------|---|-------------| | shell | Default: `/bin/bash` | | -| basename | Default: `` | | +| basename | Default: `` | | From 131a65051bc4082eb2b5e3d1687188f9065eb44d Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Fri, 18 Apr 2025 15:34:46 +0200 Subject: [PATCH 07/15] delete cassette --- ...ongodb-instance-create-usage.cassette.yaml | 36 ------------------- ...ge-rdb-instance-edit-settings-usage.golden | 28 +++++++++++++++ .../test-all-usage-rdb-instance-usage.golden | 2 +- internal/namespaces/rdb/v1/custom.go | 2 +- internal/namespaces/rdb/v1/custom_instance.go | 10 +++--- 5 files changed, 35 insertions(+), 43 deletions(-) delete mode 100644 cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml create mode 100644 cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml b/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml deleted file mode 100644 index dc97b9c177..0000000000 --- a/cmd/scw/testdata/test-all-usage-mongodb-instance-create-usage.cassette.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: '{"message":"authentication is denied","method":"api_key","reason":"not_found","type":"denied_authentication"}' - form: {} - headers: - User-Agent: - - scaleway-sdk-go/v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23 (go1.24.1; darwin; - amd64) cli-e2e-test - url: https://api.scaleway.com/mongodb/v1alpha1/regions/fr-par/versions - method: GET - response: - body: '{"message":"authentication is denied","method":"api_key","reason":"not_found","type":"denied_authentication"}' - headers: - Content-Length: - - "109" - Content-Security-Policy: - - default-src 'none'; frame-ancestors 'none' - Content-Type: - - application/json - Date: - - Thu, 17 Apr 2025 14:38:27 GMT - Server: - - Scaleway API Gateway (fr-par-3;edge03) - Strict-Transport-Security: - - max-age=63072000 - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - X-Request-Id: - - 1fdfe4ef-fffa-4161-bf2f-471785bce599 - status: 401 Unauthorized - code: 401 - duration: "" diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden new file mode 100644 index 0000000000..3c36baf48f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden @@ -0,0 +1,28 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +USAGE: + scw rdb instance edit-settings [arg=value ...] + +EXAMPLES: + Edit instance settings in YAML + scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml + + Edit instance settings in JSON + scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json + +ARGS: + instance-id ID of the instance + [mode=yaml] marshaling used when editing data (yaml | json) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for edit-settings + +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 diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden index 08d59a3bcf..0433af060e 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden @@ -14,13 +14,13 @@ AVAILABLE COMMANDS: connect Connect to an instance using locally installed CLI create Create a Database Instance delete Delete a Database Instance + edit-settings Edit instance settings in your default editor get Get a Database Instance get-certificate Get the TLS certificate of a Database Instance get-metrics Get Database Instance metrics list List Database Instances renew-certificate Renew the TLS certificate of a Database Instance restart Restart Database Instance - settings-edit Edit instance settings in your default editor update Update an instance upgrade Upgrade a Database Instance diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index c64a106cfc..e707c27c47 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -49,7 +49,7 @@ func GetCommands() *core.Commands { instanceConnectCommand(), instanceWaitCommand(), userGetURLCommand(), - instanceSettingsEditCommand(), + instanceEditSettingsCommand(), )) cmds.MustFind("rdb", "acl", "add").Override(aclAddBuilder) cmds.MustFind("rdb", "acl", "delete").Override(aclDeleteBuilder) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index 95d37684d9..c73383b217 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -927,8 +927,8 @@ func instanceConnectCommand() *core.Command { } } -func instanceSettingsEditCommand() *core.Command { - type settingsEditArgs struct { +func instanceEditSettingsCommand() *core.Command { + type editSettingsArgs struct { InstanceID string `arg:"positional,required"` Region scw.Region `arg:"required"` Mode editor.MarshalMode @@ -937,11 +937,11 @@ func instanceSettingsEditCommand() *core.Command { return &core.Command{ Namespace: "rdb", Resource: "instance", - Verb: "settings-edit", + Verb: "edit-settings", Short: "Edit instance settings in your default editor", Long: `This command opens the current settings of your RDB instance in your $EDITOR. You can modify the values and save the file to apply the new configuration.`, - ArgsType: reflect.TypeOf(settingsEditArgs{}), + ArgsType: reflect.TypeOf(editSettingsArgs{}), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", @@ -963,7 +963,7 @@ You can modify the values and save the file to apply the new configuration.`, }, }, Run: func(ctx context.Context, argsI interface{}) (interface{}, error) { - args := argsI.(*settingsEditArgs) + args := argsI.(*editSettingsArgs) client := core.ExtractClient(ctx) api := rdbSDK.NewAPI(client) From 6c6079ed3c55f1424d137311ff7f9c63fd87c6c4 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Fri, 18 Apr 2025 16:14:10 +0200 Subject: [PATCH 08/15] fix dox --- docs/commands/rdb.md | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/docs/commands/rdb.md b/docs/commands/rdb.md index 700fc981ef..3c9aafe9c2 100644 --- a/docs/commands/rdb.md +++ b/docs/commands/rdb.md @@ -43,7 +43,6 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [List Database Instances](#list-database-instances) - [Renew the TLS certificate of a Database Instance](#renew-the-tls-certificate-of-a-database-instance) - [Restart Database Instance](#restart-database-instance) - - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) - [Update an instance](#update-an-instance) - [Upgrade a Database Instance](#upgrade-a-database-instance) - [Wait for an instance to reach a stable state](#wait-for-an-instance-to-reach-a-stable-state) @@ -920,43 +919,6 @@ scw rdb instance restart [arg=value ...] -### Edit instance settings in your default editor - -This command opens the current settings of your RDB instance in your $EDITOR. -You can modify the values and save the file to apply the new configuration. - -**Usage:** - -``` -scw rdb instance settings-edit [arg=value ...] -``` - - -**Args:** - -| Name | | Description | -|------|---|-------------| -| instance-id | Required | ID of the instance | -| mode | Default: `yaml`
One of: `yaml`, `json` | marshaling used when editing data | -| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | - - -**Examples:** - - -Edit instance settings in YAML -``` -scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml -``` - -Edit instance settings in JSON -``` -scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json -``` - - - - ### Update an instance Update an instance. @@ -1438,7 +1400,7 @@ scw rdb setting delete [arg=value ...] ### Set Database Instance advanced settings -Update an advanced setting for a Database Instance. Settings added upon database engine initialization can only be defined once, and cannot, therefore, be updated. +Update an advanced setting for a Database Instance. Settings added upon database engine initalization can only be defined once, and cannot, therefore, be updated. **Usage:** From 19d966badfbe437076cef5cb9cdf2ae783ee94f1 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Fri, 18 Apr 2025 16:32:08 +0200 Subject: [PATCH 09/15] fix docs --- docs/commands/rdb.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/commands/rdb.md b/docs/commands/rdb.md index 3c9aafe9c2..d6cab4a002 100644 --- a/docs/commands/rdb.md +++ b/docs/commands/rdb.md @@ -37,6 +37,7 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [Connect to an instance using locally installed CLI](#connect-to-an-instance-using-locally-installed-cli) - [Create a Database Instance](#create-a-database-instance) - [Delete a Database Instance](#delete-a-database-instance) + - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) - [Get a Database Instance](#get-a-database-instance) - [Get the TLS certificate of a Database Instance](#get-the-tls-certificate-of-a-database-instance) - [Get Database Instance metrics](#get-database-instance-metrics) @@ -792,6 +793,43 @@ scw rdb instance delete [arg=value ...] +### Edit instance settings in your default editor + +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +**Usage:** + +``` +scw rdb instance edit-settings [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| instance-id | Required | ID of the instance | +| mode | Default: `yaml`
One of: `yaml`, `json` | marshaling used when editing data | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + +**Examples:** + + +Edit instance settings in YAML +``` +scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml +``` + +Edit instance settings in JSON +``` +scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json +``` + + + + ### Get a Database Instance Retrieve information about a given Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. @@ -1400,7 +1438,7 @@ scw rdb setting delete [arg=value ...] ### Set Database Instance advanced settings -Update an advanced setting for a Database Instance. Settings added upon database engine initalization can only be defined once, and cannot, therefore, be updated. +Update an advanced setting for a Database Instance. Settings added upon database engine initialization can only be defined once, and cannot, therefore, be updated. **Usage:** From b76de949dfc1db5ac453ce21059157b681e66ba6 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Tue, 22 Apr 2025 10:24:31 +0200 Subject: [PATCH 10/15] fix golden --- ...ge-rdb-instance-edit-settings-usage.golden | 4 +-- ...ge-rdb-instance-settings-edit-usage.golden | 28 ------------------- 2 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden index 3c36baf48f..55ec3ac7f1 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-edit-settings-usage.golden @@ -8,10 +8,10 @@ USAGE: EXAMPLES: Edit instance settings in YAML - scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml + scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml Edit instance settings in JSON - scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json + scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json ARGS: instance-id ID of the instance diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden deleted file mode 100644 index fd69e2548b..0000000000 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-settings-edit-usage.golden +++ /dev/null @@ -1,28 +0,0 @@ -🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 -πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ -This command opens the current settings of your RDB instance in your $EDITOR. -You can modify the values and save the file to apply the new configuration. - -USAGE: - scw rdb instance settings-edit [arg=value ...] - -EXAMPLES: - Edit instance settings in YAML - scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml - - Edit instance settings in JSON - scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json - -ARGS: - instance-id ID of the instance - [mode=yaml] marshaling used when editing data (yaml | json) - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) - -FLAGS: - -h, --help help for settings-edit - -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 From f69716c736e98e3d405db1837d1f107afb732c43 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Tue, 22 Apr 2025 10:33:40 +0200 Subject: [PATCH 11/15] fix test --- internal/namespaces/rdb/v1/custom_instance.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index c73383b217..634fde7744 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -955,11 +955,11 @@ You can modify the values and save the file to apply the new configuration.`, Examples: []*core.Example{ { Short: "Edit instance settings in YAML", - Raw: "scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml", + Raw: "scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml", }, { Short: "Edit instance settings in JSON", - Raw: "scw rdb instance settings-edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json", + Raw: "scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json", }, }, Run: func(ctx context.Context, argsI interface{}) (interface{}, error) { From d1d6be76344b2dd49a3f8e9bd25c738847858118 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Wed, 23 Apr 2025 14:19:55 +0200 Subject: [PATCH 12/15] moved setting cmd --- .../test-all-usage-rdb-instance-usage.golden | 1 - ...st-all-usage-rdb-setting-edit-usage.golden | 28 +++++++ .../test-all-usage-rdb-setting-usage.golden | 1 + docs/commands/rdb.md | 76 +++++++++---------- 4 files changed, 67 insertions(+), 39 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-rdb-setting-edit-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden index 0433af060e..a1665b6816 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden @@ -14,7 +14,6 @@ AVAILABLE COMMANDS: connect Connect to an instance using locally installed CLI create Create a Database Instance delete Delete a Database Instance - edit-settings Edit instance settings in your default editor get Get a Database Instance get-certificate Get the TLS certificate of a Database Instance get-metrics Get Database Instance metrics diff --git a/cmd/scw/testdata/test-all-usage-rdb-setting-edit-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-setting-edit-usage.golden new file mode 100644 index 0000000000..590ce09cc9 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-setting-edit-usage.golden @@ -0,0 +1,28 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +USAGE: + scw rdb setting edit [arg=value ...] + +EXAMPLES: + Edit instance settings in YAML + scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml + + Edit instance settings in JSON + scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json + +ARGS: + instance-id ID of the instance + [mode=yaml] marshaling used when editing data (yaml | json) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for edit + +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 diff --git a/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden index 616a28479e..453ccd29a9 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden @@ -12,6 +12,7 @@ USAGE: AVAILABLE COMMANDS: add Add Database Instance advanced settings delete Delete Database Instance advanced settings + edit Edit instance settings in your default editor set Set Database Instance advanced settings FLAGS: diff --git a/docs/commands/rdb.md b/docs/commands/rdb.md index d6cab4a002..a173a9dccf 100644 --- a/docs/commands/rdb.md +++ b/docs/commands/rdb.md @@ -37,7 +37,6 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [Connect to an instance using locally installed CLI](#connect-to-an-instance-using-locally-installed-cli) - [Create a Database Instance](#create-a-database-instance) - [Delete a Database Instance](#delete-a-database-instance) - - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) - [Get a Database Instance](#get-a-database-instance) - [Get the TLS certificate of a Database Instance](#get-the-tls-certificate-of-a-database-instance) - [Get Database Instance metrics](#get-database-instance-metrics) @@ -67,6 +66,7 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [Setting management](#setting-management) - [Add Database Instance advanced settings](#add-database-instance-advanced-settings) - [Delete Database Instance advanced settings](#delete-database-instance-advanced-settings) + - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) - [Set Database Instance advanced settings](#set-database-instance-advanced-settings) - [Block snapshot management](#block-snapshot-management) - [Create a Database Instance snapshot](#create-a-database-instance-snapshot) @@ -793,43 +793,6 @@ scw rdb instance delete [arg=value ...] -### Edit instance settings in your default editor - -This command opens the current settings of your RDB instance in your $EDITOR. -You can modify the values and save the file to apply the new configuration. - -**Usage:** - -``` -scw rdb instance edit-settings [arg=value ...] -``` - - -**Args:** - -| Name | | Description | -|------|---|-------------| -| instance-id | Required | ID of the instance | -| mode | Default: `yaml`
One of: `yaml`, `json` | marshaling used when editing data | -| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | - - -**Examples:** - - -Edit instance settings in YAML -``` -scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml -``` - -Edit instance settings in JSON -``` -scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json -``` - - - - ### Get a Database Instance Retrieve information about a given Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. @@ -1436,6 +1399,43 @@ scw rdb setting delete [arg=value ...] +### Edit instance settings in your default editor + +This command opens the current settings of your RDB instance in your $EDITOR. +You can modify the values and save the file to apply the new configuration. + +**Usage:** + +``` +scw rdb setting edit [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| instance-id | Required | ID of the instance | +| mode | Default: `yaml`
One of: `yaml`, `json` | marshaling used when editing data | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + +**Examples:** + + +Edit instance settings in YAML +``` +scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml +``` + +Edit instance settings in JSON +``` +scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json +``` + + + + ### Set Database Instance advanced settings Update an advanced setting for a Database Instance. Settings added upon database engine initialization can only be defined once, and cannot, therefore, be updated. From aa433854a4716ec360066417648ca9334ec58269 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Wed, 23 Apr 2025 14:41:22 +0200 Subject: [PATCH 13/15] fix test --- internal/namespaces/rdb/v1/custom_instance.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index 634fde7744..a255365d48 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -936,9 +936,9 @@ func instanceEditSettingsCommand() *core.Command { return &core.Command{ Namespace: "rdb", - Resource: "instance", - Verb: "edit-settings", - Short: "Edit instance settings in your default editor", + Resource: "setting", + Verb: "edit", + Short: "Edit Database Instance settings in your default editor", Long: `This command opens the current settings of your RDB instance in your $EDITOR. You can modify the values and save the file to apply the new configuration.`, ArgsType: reflect.TypeOf(editSettingsArgs{}), @@ -955,11 +955,11 @@ You can modify the values and save the file to apply the new configuration.`, Examples: []*core.Example{ { Short: "Edit instance settings in YAML", - Raw: "scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml", + Raw: "scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=yaml", }, { Short: "Edit instance settings in JSON", - Raw: "scw rdb instance edit-settings 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json", + Raw: "scw rdb setting edit 12345678-1234-1234-1234-123456789abc --region=fr-par --mode=json", }, }, Run: func(ctx context.Context, argsI interface{}) (interface{}, error) { From 0a1a6e0fba7ec456cf45d8067b36f4e41370b9a9 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Wed, 23 Apr 2025 14:44:29 +0200 Subject: [PATCH 14/15] fix doc --- docs/commands/rdb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/commands/rdb.md b/docs/commands/rdb.md index a173a9dccf..73bfca6b90 100644 --- a/docs/commands/rdb.md +++ b/docs/commands/rdb.md @@ -66,7 +66,7 @@ This API allows you to manage your Managed Databases for PostgreSQL and MySQL. - [Setting management](#setting-management) - [Add Database Instance advanced settings](#add-database-instance-advanced-settings) - [Delete Database Instance advanced settings](#delete-database-instance-advanced-settings) - - [Edit instance settings in your default editor](#edit-instance-settings-in-your-default-editor) + - [Edit Database Instance settings in your default editor](#edit-database-instance-settings-in-your-default-editor) - [Set Database Instance advanced settings](#set-database-instance-advanced-settings) - [Block snapshot management](#block-snapshot-management) - [Create a Database Instance snapshot](#create-a-database-instance-snapshot) @@ -1399,7 +1399,7 @@ scw rdb setting delete [arg=value ...] -### Edit instance settings in your default editor +### Edit Database Instance settings in your default editor This command opens the current settings of your RDB instance in your $EDITOR. You can modify the values and save the file to apply the new configuration. From ef03805545948c8b67e39bc1066371d302275b54 Mon Sep 17 00:00:00 2001 From: devtools-ci-cd Date: Wed, 23 Apr 2025 14:54:45 +0200 Subject: [PATCH 15/15] fix test all usage --- cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden index 453ccd29a9..35e20ae4e3 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-setting-usage.golden @@ -12,7 +12,7 @@ USAGE: AVAILABLE COMMANDS: add Add Database Instance advanced settings delete Delete Database Instance advanced settings - edit Edit instance settings in your default editor + edit Edit Database Instance settings in your default editor set Set Database Instance advanced settings FLAGS: