From 59677b56227bb70c6d9df1881f3793fb999a4a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 13 Jul 2020 11:52:05 +0200 Subject: [PATCH] rdb: add instance connect (#1170) --- ...ll-usage-rdb-instance-connect-usage.golden | 22 + .../test-all-usage-rdb-instance-usage.golden | 1 + internal/namespaces/rdb/v1/custom.go | 1 + internal/namespaces/rdb/v1/custom_instance.go | 192 ++++++ .../namespaces/rdb/v1/custom_instance_test.go | 44 +- internal/namespaces/rdb/v1/helper_test.go | 2 +- .../testdata/test-connect-mysql.cassette.yaml | 581 ++++++++++++++++++ .../rdb/v1/testdata/test-connect-mysql.golden | 3 + .../testdata/test-connect-psql.cassette.yaml | 581 ++++++++++++++++++ .../rdb/v1/testdata/test-connect-psql.golden | 3 + 10 files changed, 1426 insertions(+), 4 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-rdb-instance-connect-usage.golden create mode 100644 internal/namespaces/rdb/v1/testdata/test-connect-mysql.cassette.yaml create mode 100644 internal/namespaces/rdb/v1/testdata/test-connect-mysql.golden create mode 100644 internal/namespaces/rdb/v1/testdata/test-connect-psql.cassette.yaml create mode 100644 internal/namespaces/rdb/v1/testdata/test-connect-psql.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-connect-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-connect-usage.golden new file mode 100644 index 0000000000..44ed4b51ad --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-connect-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Connect to an instance using locally installed CLI such as psql or mysql. + +USAGE: + scw rdb instance connect [arg=value ...] + +ARGS: + instance-id UUID of the instance + username Name of the user to connect with to the database + [database=rdb] Name of the database + [cli-db] Command line tool to use, default to psql/mysql + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + +FLAGS: + -h, --help help for connect + +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 40ff3f67ce..265c444249 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-usage.golden @@ -7,6 +7,7 @@ USAGE: AVAILABLE COMMANDS: clone Clone an instance + connect Connect to an instance using locally installed CLI create Create an instance delete Delete an instance get Get an instance diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index 9763b77c55..ece0383302 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -26,6 +26,7 @@ func GetCommands() *core.Commands { cmds.Merge(core.NewCommands( instanceWaitCommand(), + instanceConnectCommand(), )) cmds.MustFind("rdb", "instance", "create").Override(instanceCreateBuilder) cmds.MustFind("rdb", "instance", "clone").Override(instanceCloneBuilder) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index a1910c8e76..610969cfe7 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -2,12 +2,18 @@ package rdb import ( "context" + "fmt" + "os" + "os/exec" + "path" "reflect" + "runtime" "strings" "time" "github.com/scaleway/scaleway-cli/internal/core" "github.com/scaleway/scaleway-cli/internal/human" + "github.com/scaleway/scaleway-cli/internal/interactive" "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) @@ -165,3 +171,189 @@ func instanceWaitCommand() *core.Command { }, } } + +type instanceConnectArgs struct { + Region scw.Region + InstanceID string + Username string + Database *string + CliDB *string +} + +type engineFamily string + +const ( + Unknown = engineFamily("Unknown") + PostgreSQL = engineFamily("PostgreSQL") + MySQL = engineFamily("MySQL") + postgreSQLHint = ` +psql supports password file to avoid typing your password manually. +Learn more at: https://www.postgresql.org/docs/current/libpq-pgpass.html` + mySQLHint = ` +mysql supports loading your password from a file to avoid typing them manually. +Learn more at: https://dev.mysql.com/doc/refman/8.0/en/option-files.html` +) + +func passwordFileExist(ctx context.Context, family engineFamily) bool { + passwordFilePath := "" + switch family { + case PostgreSQL: + switch runtime.GOOS { + case "windows": + passwordFilePath = path.Join(core.ExtractUserHomeDir(ctx), core.ExtractEnv(ctx, "APPDATA"), "postgresql", "pgpass.conf") + default: + passwordFilePath = path.Join(core.ExtractUserHomeDir(ctx), ".pgpass") + } + case MySQL: + passwordFilePath = path.Join(core.ExtractUserHomeDir(ctx), ".my.cnf") + default: + return false + } + if passwordFilePath == "" { + return false + } + _, err := os.Stat(passwordFilePath) + return err == nil +} + +func passwordFileHint(family engineFamily) string { + switch family { + case PostgreSQL: + return postgreSQLHint + case MySQL: + return mySQLHint + default: + return "" + } +} + +func detectEngineFamily(instance *rdb.Instance) (engineFamily, error) { + if instance == nil { + return Unknown, fmt.Errorf("instance engine is nil") + } + if strings.HasPrefix(instance.Engine, string(PostgreSQL)) { + return PostgreSQL, nil + } + if strings.HasPrefix(instance.Engine, string(MySQL)) { + return MySQL, nil + } + return Unknown, fmt.Errorf("unknown engine: %s", instance.Engine) +} + +func createConnectCommandLineArgs(instance *rdb.Instance, family engineFamily, args *instanceConnectArgs) ([]string, error) { + database := "rdb" + if args.Database != nil { + database = *args.Database + } + + switch family { + case PostgreSQL: + clidb := "psql" + if args.CliDB != nil { + clidb = *args.CliDB + } + + // psql -h 51.159.25.206 --port 13917 -d rdb -U username + return []string{ + clidb, + "--host", instance.Endpoint.IP.String(), + "--port", fmt.Sprintf("%d", instance.Endpoint.Port), + "--username", args.Username, + "--dbname", database, + }, nil + case MySQL: + clidb := "mysql" + if args.CliDB != nil { + clidb = *args.CliDB + } + + // mysql -h 195.154.69.163 --port 12210 -p -u username + return []string{ + clidb, + "--host", instance.Endpoint.IP.String(), + "--port", fmt.Sprintf("%d", instance.Endpoint.Port), + "--database", database, + "--user", args.Username, + }, nil + } + + return nil, fmt.Errorf("unrecognize database engine: %s", instance.Engine) +} + +func instanceConnectCommand() *core.Command { + return &core.Command{ + Namespace: "rdb", + Resource: "instance", + Verb: "connect", + Short: "Connect to an instance using locally installed CLI", + Long: "Connect to an instance using locally installed CLI such as psql or mysql.", + ArgsType: reflect.TypeOf(instanceConnectArgs{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "instance-id", + Short: `UUID of the instance`, + Required: true, + Positional: true, + }, + { + Name: "username", + Short: "Name of the user to connect with to the database", + Required: true, + }, + { + Name: "database", + Short: "Name of the database", + Default: core.DefaultValueSetter("rdb"), + }, + { + Name: "cli-db", + Short: "Command line tool to use, default to psql/mysql", + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + }, + Run: func(ctx context.Context, argsI interface{}) (interface{}, error) { + args := argsI.(*instanceConnectArgs) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + instance, err := api.GetInstance(&rdb.GetInstanceRequest{ + Region: args.Region, + InstanceID: args.InstanceID, + }) + if err != nil { + return nil, err + } + + engineFamily, err := detectEngineFamily(instance) + if err != nil { + return nil, err + } + + cmdArgs, err := createConnectCommandLineArgs(instance, engineFamily, args) + if err != nil { + return nil, err + } + + if !passwordFileExist(ctx, engineFamily) { + interactive.Println(passwordFileHint(engineFamily)) + } + + // Run command + cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...) //nolint:gosec + //cmd.Stdin = os.Stdin + core.ExtractLogger(ctx).Debugf("executing: %s\n", cmd.Args) + exitCode, err := core.ExecCmd(ctx, cmd) + + if err != nil { + return nil, err + } + if exitCode != 0 { + return nil, &core.CliError{Empty: true, Code: exitCode} + } + + return &core.SuccessResult{ + Empty: true, // the program will output the success message + }, nil + }, + } +} diff --git a/internal/namespaces/rdb/v1/custom_instance_test.go b/internal/namespaces/rdb/v1/custom_instance_test.go index ee1ffcdc53..7c07c8949d 100644 --- a/internal/namespaces/rdb/v1/custom_instance_test.go +++ b/internal/namespaces/rdb/v1/custom_instance_test.go @@ -10,7 +10,7 @@ import ( func Test_CloneInstance(t *testing.T) { t.Run("Simple", core.Test(&core.TestConfig{ Commands: GetCommands(), - BeforeFunc: createInstance(), + BeforeFunc: createInstance("PostgreSQL-12"), Cmd: "scw rdb instance clone {{ .Instance.ID }} node-type=DB-DEV-M name=foobar --wait", Check: core.TestCheckGolden(), AfterFunc: deleteInstance(), @@ -29,7 +29,7 @@ func Test_CreateInstance(t *testing.T) { func Test_GetInstance(t *testing.T) { t.Run("Simple", core.Test(&core.TestConfig{ Commands: GetCommands(), - BeforeFunc: createInstance(), + BeforeFunc: createInstance("PostgreSQL-12"), Cmd: "scw rdb instance get {{ .Instance.ID }}", Check: core.TestCheckGolden(), AfterFunc: deleteInstance(), @@ -39,9 +39,47 @@ func Test_GetInstance(t *testing.T) { func Test_UpgradeInstance(t *testing.T) { t.Run("Simple", core.Test(&core.TestConfig{ Commands: GetCommands(), - BeforeFunc: createInstance(), + BeforeFunc: createInstance("PostgreSQL-12"), Cmd: "scw rdb instance upgrade {{ .Instance.ID }} node-type=DB-DEV-M --wait", Check: core.TestCheckGolden(), AfterFunc: deleteInstance(), })) } + +func Test_Connect(t *testing.T) { + t.Run("mysql", core.Test(&core.TestConfig{ + Commands: GetCommands(), + BeforeFunc: core.BeforeFuncCombine( + func(ctx *core.BeforeFuncCtx) error { + ctx.Meta["username"] = user + return nil + }, + createInstance("MySQL-8"), + ), + Cmd: "scw rdb instance connect {{ .Instance.ID }} username={{ .username }}", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + OverrideExec: core.OverrideExecSimple("mysql --host {{ .Instance.Endpoint.IP }} --port {{ .Instance.Endpoint.Port }} --database rdb --user {{ .username }}", 0), + AfterFunc: deleteInstance(), + })) + + t.Run("psql", core.Test(&core.TestConfig{ + Commands: GetCommands(), + BeforeFunc: core.BeforeFuncCombine( + func(ctx *core.BeforeFuncCtx) error { + ctx.Meta["username"] = user + return nil + }, + createInstance("PostgreSQL-12"), + ), + Cmd: "scw rdb instance connect {{ .Instance.ID }} username={{ .username }}", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + OverrideExec: core.OverrideExecSimple("psql --host {{ .Instance.Endpoint.IP }} --port {{ .Instance.Endpoint.Port }} --username {{ .username }} --dbname rdb", 0), + AfterFunc: deleteInstance(), + })) +} diff --git a/internal/namespaces/rdb/v1/helper_test.go b/internal/namespaces/rdb/v1/helper_test.go index ee45f05669..995dfcad5d 100644 --- a/internal/namespaces/rdb/v1/helper_test.go +++ b/internal/namespaces/rdb/v1/helper_test.go @@ -13,7 +13,7 @@ const ( engine = "PostgreSQL-12" ) -func createInstance() core.BeforeFunc { +func createInstance(engine string) core.BeforeFunc { return core.ExecStoreBeforeCmd( "Instance", fmt.Sprintf("scw rdb instance create node-type=DB-DEV-S is-ha-cluster=false name=%s engine=%s user-name=%s password=%s --wait", name, engine, user, password), diff --git a/internal/namespaces/rdb/v1/testdata/test-connect-mysql.cassette.yaml b/internal/namespaces/rdb/v1/testdata/test-connect-mysql.cassette.yaml new file mode 100644 index 0000000000..9d15a30beb --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-connect-mysql.cassette.yaml @@ -0,0 +1,581 @@ +--- +version: 1 +interactions: +- request: + body: '{"organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"cli-test","engine":"MySQL-8","user_name":"foobar","password":"{4xdl*#QOoP+\u00263XRkGA)]","node_type":"db-dev-s","is_ha_cluster":false,"disable_backup":false,"tags":null}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances + method: POST + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:09:02 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b26a9912-a036-44e9-b17a-8b954d407523 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:09:02 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 27d32247-a815-4cc2-8f47-95992fe351e7 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:09:17 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 894a9cfa-4116-4f0c-998d-0a975d3d767c + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:09:32 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - e0b6a5d1-6f45-4e40-8b5b-58a73fe89038 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:09:47 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c3ff2eed-72b2-40d3-9b12-b701bafdd869 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:10:02 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 74ae0349-8a31-4375-bc17-b435d0b5f7a9 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:10:17 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3e83f229-92d3-4225-840b-a2b11e577dd1 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:10:33 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - d69f956c-2374-40b7-9ef0-6695d663ed4b + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:10:48 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c7fb0e5d-8799-4f19-9c5b-11dcb586d5bc + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:11:03 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f382f911-303a-45bc-b59c-a12be41e2b49 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:11:18 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 00305e63-8b43-40e2-99ba-f8be95bb80cb + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:11:33 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fcbd0276-430f-46fe-9290-34165eb47c66 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:11:48 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c05c5902-0739-482e-bdc6-be685d3d1a10 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:04 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b661785a-9419-4544-b49d-c12b57598d37 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"MySQL-8","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "437" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:19 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 2877d197-72cf-4dea-9788-90bc95d06811 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"MySQL-8","endpoint":{"ip":"51.159.25.206","port":39832,"name":null},"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "473" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:34 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - d000c4f8-aa12-4d90-bd4d-49c801dd0228 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: GET + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"MySQL-8","endpoint":{"ip":"51.159.25.206","port":39832,"name":null},"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "473" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:34 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - cd4ed203-2405-4a72-8ea7-33c58e2d4ff3 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/8b5cb2f9-c35a-4063-afaa-111014f1dcf0 + method: DELETE + response: + body: '{"id":"8b5cb2f9-c35a-4063-afaa-111014f1dcf0","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"deleting","engine":"MySQL-8","endpoint":{"ip":"51.159.25.206","port":39832,"name":null},"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":true},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:09:01.497395Z","region":"fr-par"}' + headers: + Content-Length: + - "475" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:36 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 191124ab-cb08-4ce3-9c4e-7146ae857cbd + status: 200 OK + code: 200 + duration: "" diff --git a/internal/namespaces/rdb/v1/testdata/test-connect-mysql.golden b/internal/namespaces/rdb/v1/testdata/test-connect-mysql.golden new file mode 100644 index 0000000000..995ad766aa --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-connect-mysql.golden @@ -0,0 +1,3 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{} diff --git a/internal/namespaces/rdb/v1/testdata/test-connect-psql.cassette.yaml b/internal/namespaces/rdb/v1/testdata/test-connect-psql.cassette.yaml new file mode 100644 index 0000000000..07155e5d85 --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-connect-psql.cassette.yaml @@ -0,0 +1,581 @@ +--- +version: 1 +interactions: +- request: + body: '{"organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"cli-test","engine":"PostgreSQL-12","user_name":"foobar","password":"{4xdl*#QOoP+\u00263XRkGA)]","node_type":"db-dev-s","is_ha_cluster":false,"disable_backup":false,"tags":null}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances + method: POST + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:51 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - efe1b8e2-f8c3-4625-a44b-3306497f39c3 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:12:51 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f0c1164f-39a8-4ad9-b07d-d2fa3a638537 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:13:06 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - bc993695-be72-4008-b78b-f2c41fdc2244 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:13:21 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 4320b9c5-ff34-4c26-81da-c6e6c196f2b7 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:13:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - d8a2f913-a0be-416c-9cb2-2b380f20c021 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:13:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 09057d30-0e5c-4378-984a-46e57acffd91 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:14:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 7d68c6fb-9db3-4001-8525-f3a3729dd6c6 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:14:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 118078ec-109e-471c-a28a-effcd2ecc30b + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:14:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b533b9df-2aea-49c5-a2fd-f1a01c5b8b54 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:14:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - eef13cd3-658b-4d05-9286-0386fde75cb8 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:15:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 707a6a1a-5dfe-4e25-a041-67d0c9790697 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:15:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - cbcee6bf-ce74-48a4-8571-b7f65e2ba89d + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:15:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 8ca010e8-cbc3-47a4-9280-6e16da4c556e + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:15:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3821b8e5-52bf-46f9-9e22-9e1d5bb6611b + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.25.206","port":61486,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "750" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:16:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b18fecb8-fb1e-4313-ad80-aa929db1da4d + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.25.206","port":61486,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "743" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:16:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a468d4b1-c4e8-47a5-b73b-d0c4733932bc + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: GET + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.25.206","port":61486,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "743" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:16:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b42d31d4-9285-42df-b4aa-4ec2e08198ba + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.4; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2a29ad6a-91b1-4d4d-b34e-22a07c48cb38 + method: DELETE + response: + body: '{"id":"2a29ad6a-91b1-4d4d-b34e-22a07c48cb38","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"deleting","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.25.206","port":61486,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":true},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-07-13T09:12:49.988945Z","region":"fr-par"}' + headers: + Content-Length: + - "745" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 13 Jul 2020 09:16:24 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3f3b4ed4-b6d6-4864-b3ea-d30f45290194 + status: 200 OK + code: 200 + duration: "" diff --git a/internal/namespaces/rdb/v1/testdata/test-connect-psql.golden b/internal/namespaces/rdb/v1/testdata/test-connect-psql.golden new file mode 100644 index 0000000000..995ad766aa --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-connect-psql.golden @@ -0,0 +1,3 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{}