From 5637814e64fba2a71a02a19c2c2549de9a421c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 6 Jul 2020 11:40:11 +0200 Subject: [PATCH 1/6] rdb: refactor engine list output --- internal/namespaces/rdb/v1/custom.go | 2 + .../namespaces/rdb/v1/custom_engine_list.go | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 internal/namespaces/rdb/v1/custom_engine_list.go diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index abf2baf80c..4591e7e6d1 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -12,5 +12,7 @@ func GetCommands() *core.Commands { cmds.MustFind("rdb", "instance", "clone").Override(instanceCloneBuilder) cmds.MustFind("rdb", "instance", "upgrade").Override(instanceUpgradeBuilder) + cmds.MustFind("rdb", "engine", "list").Override(engineListBuilder) + return cmds } diff --git a/internal/namespaces/rdb/v1/custom_engine_list.go b/internal/namespaces/rdb/v1/custom_engine_list.go new file mode 100644 index 0000000000..3d00778dbf --- /dev/null +++ b/internal/namespaces/rdb/v1/custom_engine_list.go @@ -0,0 +1,56 @@ +package rdb + +import ( + "context" + "time" + + "github.com/scaleway/scaleway-cli/internal/core" + "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" +) + +func engineListBuilder(c *core.Command) *core.Command { + type customList struct { + Name string + EngineType string + EndOfLife time.Time + } + + c.View = &core.View{ + Fields: []*core.ViewField{ + { + Label: "Name", + FieldName: "Name", + }, + { + Label: "Engine Type", + FieldName: "EngineType", + }, + { + Label: "End of Life", + FieldName: "EndOfLife", + }, + }, + } + + c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (i interface{}, err error) { + listEngineResp, err := runner(ctx, argsI) + if err != nil { + return listEngineResp, err + } + engineList := listEngineResp.([]*rdb.DatabaseEngine) + var res []customList + for _, engine := range engineList { + for _, version := range engine.Versions { + res = append(res, customList{ + Name: version.Name, + EngineType: engine.Name, + EndOfLife: version.EndOfLife, + }) + } + } + + return res, nil + }) + + return c +} From 49afdee85e32d0efadc8ce113b5d04224a67bc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 6 Jul 2020 11:48:20 +0200 Subject: [PATCH 2/6] Fix --- .../rdb/v1/custom_engine_list_test.go | 18 ++ .../test-engine-list-simple.cassette.yaml | 159 ++++++++++++++++++ .../testdata/test-engine-list-simple.golden | 36 ++++ 3 files changed, 213 insertions(+) create mode 100644 internal/namespaces/rdb/v1/custom_engine_list_test.go create mode 100644 internal/namespaces/rdb/v1/testdata/test-engine-list-simple.cassette.yaml create mode 100644 internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden diff --git a/internal/namespaces/rdb/v1/custom_engine_list_test.go b/internal/namespaces/rdb/v1/custom_engine_list_test.go new file mode 100644 index 0000000000..5c82026fb5 --- /dev/null +++ b/internal/namespaces/rdb/v1/custom_engine_list_test.go @@ -0,0 +1,18 @@ +package rdb + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/internal/core" +) + +func Test_EngineList(t *testing.T) { + t.Run("Simple", core.Test(&core.TestConfig{ + Commands: GetCommands(), + Cmd: "scw rdb engine list", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + })) +} diff --git a/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.cassette.yaml b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.cassette.yaml new file mode 100644 index 0000000000..a5c82728f3 --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.cassette.yaml @@ -0,0 +1,159 @@ +--- +version: 1 +interactions: +- 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/database-engines?page=1 + method: GET + response: + body: '{"engines":[{"name":"PostgreSQL","logo_url":"https://s3.nl-ams.scw.cloud/scw-rdb-logos/postgresql.svg","versions":[{"version":"12","name":"PostgreSQL-12","end_of_life":"2024-11-14T00:00:00Z","available_settings":[{"name":"max_locks_per_transaction","default_value":"64","hot_configurable":false,"description":"Sets + the maximum number of locks per transaction.","property_type":"INT","unit":null,"string_constraint":null,"int_min":10,"int_max":2147483647},{"name":"tcp_keepalives_idle","default_value":"0","hot_configurable":true,"description":"Time + between issuing TCP keepalives.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"statement_timeout","default_value":"86400000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any statement. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":30000,"int_max":2147483647},{"name":"default_statistics_target","default_value":"100","hot_configurable":true,"description":"Sets + the default statistics target.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"lock_timeout","default_value":"0","hot_configurable":false,"description":"Sets + the maximum allowed duration of any wait for a lock.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"work_mem","default_value":"4","hot_configurable":true,"description":"Sets + the maximum memory to be used for query workspaces.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"temp_buffers","default_value":"8192","hot_configurable":true,"description":"Sets + the maximum number of temporary buffers used by each session.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":800,"int_max":1073741824},{"name":"idle_in_transaction_session_timeout","default_value":"3600000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any idling transaction. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"max_connections","default_value":"100","hot_configurable":false,"description":"Sets + the maximum number of concurrent connections.","property_type":"INT","unit":null,"string_constraint":null,"int_min":50,"int_max":10000},{"name":"maintenance_work_mem","default_value":"64","hot_configurable":true,"description":"Sets + the maximum memory to be used for maintenance operations.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"default_transaction_deferrable","default_value":"off","hot_configurable":true,"description":"Sets + the default deferrable status of new transactions.","property_type":"BOOLEAN","unit":null,"string_constraint":null,"int_min":null,"int_max":null},{"name":"tcp_keepalives_interval","default_value":"0","hot_configurable":true,"description":"Time + between TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"commit_delay","default_value":"0","hot_configurable":true,"description":"Sets + the delay in microseconds between transaction commit and flushing WAL to disk.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":100000},{"name":"tcp_keepalives_count","default_value":"0","hot_configurable":true,"description":"Maximum + number of TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"temp_file_limit","default_value":"-1","hot_configurable":false,"description":"Limits + the total size of all temporary files used by each session.","property_type":"INT","unit":null,"string_constraint":null,"int_min":-1,"int_max":2147483647},{"name":"max_parallel_workers","default_value":"8","hot_configurable":true,"description":"Sets + the maximum number of parallel workers that can be active at one time.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"effective_cache_size","default_value":"4096","hot_configurable":true,"description":"Sets + the planner s assumption about the size of the data cache.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":64,"int_max":1048576},{"name":"max_parallel_workers_per_gather","default_value":"2","hot_configurable":true,"description":"Sets + the maximum number of parallel processes per executor node.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"vacuum_cost_delay","default_value":"0","hot_configurable":true,"description":"Vacuum + cost delay in milliseconds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":100},{"name":"vacuum_cost_page_hit","default_value":"1","hot_configurable":true,"description":"Vacuum + cost for a page found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_miss","default_value":"10","hot_configurable":true,"description":"Vacuum + cost for a page not found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_dirty","default_value":"20","hot_configurable":true,"description":"Vacuum + cost for a page dirtied by vacuum.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_limit","default_value":"200","hot_configurable":true,"description":"Vacuum + cost amount available before napping.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"bgwriter_delay","default_value":"200","hot_configurable":true,"description":"Background + writer sleep time between rounds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":10,"int_max":10000},{"name":"bgwriter_lru_maxpages","default_value":"100","hot_configurable":true,"description":"Background + writer maximum number of LRU pages to flush per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1073741823},{"name":"bgwriter_lru_multiplier","default_value":"2","hot_configurable":true,"description":"Multiple + of the average buffer usage to free per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10},{"name":"bgwriter_flush_after","default_value":"512","hot_configurable":true,"description":"Number + of pages after which previously performed writes are flushed to disk.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":0,"int_max":2048},{"name":"deadlock_timeout","default_value":"1000","hot_configurable":true,"description":"Sets + the time to wait on a lock before checking for deadlock.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":100,"int_max":60000}],"disabled":false,"beta":false},{"version":"11","name":"PostgreSQL-11","end_of_life":"2023-11-09T00:00:00Z","available_settings":[{"name":"max_locks_per_transaction","default_value":"64","hot_configurable":false,"description":"Sets + the maximum number of locks per transaction.","property_type":"INT","unit":null,"string_constraint":null,"int_min":10,"int_max":2147483647},{"name":"tcp_keepalives_idle","default_value":"0","hot_configurable":true,"description":"Time + between issuing TCP keepalives.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"statement_timeout","default_value":"86400000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any statement. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":30000,"int_max":2147483647},{"name":"default_statistics_target","default_value":"100","hot_configurable":true,"description":"Sets + the default statistics target.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"lock_timeout","default_value":"0","hot_configurable":false,"description":"Sets + the maximum allowed duration of any wait for a lock.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"work_mem","default_value":"4","hot_configurable":true,"description":"Sets + the maximum memory to be used for query workspaces.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"temp_buffers","default_value":"8192","hot_configurable":true,"description":"Sets + the maximum number of temporary buffers used by each session.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":800,"int_max":1073741824},{"name":"idle_in_transaction_session_timeout","default_value":"3600000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any idling transaction. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"max_connections","default_value":"100","hot_configurable":false,"description":"Sets + the maximum number of concurrent connections.","property_type":"INT","unit":null,"string_constraint":null,"int_min":50,"int_max":10000},{"name":"maintenance_work_mem","default_value":"64","hot_configurable":true,"description":"Sets + the maximum memory to be used for maintenance operations.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"default_transaction_deferrable","default_value":"off","hot_configurable":true,"description":"Sets + the default deferrable status of new transactions.","property_type":"BOOLEAN","unit":null,"string_constraint":null,"int_min":null,"int_max":null},{"name":"tcp_keepalives_interval","default_value":"0","hot_configurable":true,"description":"Time + between TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"commit_delay","default_value":"0","hot_configurable":true,"description":"Sets + the delay in microseconds between transaction commit and flushing WAL to disk.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":100000},{"name":"tcp_keepalives_count","default_value":"0","hot_configurable":true,"description":"Maximum + number of TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"temp_file_limit","default_value":"-1","hot_configurable":false,"description":"Limits + the total size of all temporary files used by each session.","property_type":"INT","unit":null,"string_constraint":null,"int_min":-1,"int_max":2147483647},{"name":"deadlock_timeout","default_value":"1000","hot_configurable":true,"description":"Sets + the time to wait on a lock before checking for deadlock.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":100,"int_max":60000},{"name":"max_parallel_workers","default_value":"8","hot_configurable":true,"description":"Sets + the maximum number of parallel workers that can be active at one time.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"effective_cache_size","default_value":"4096","hot_configurable":true,"description":"Sets + the planner s assumption about the size of the data cache.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":64,"int_max":1048576},{"name":"max_parallel_workers_per_gather","default_value":"2","hot_configurable":true,"description":"Sets + the maximum number of parallel processes per executor node.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"vacuum_cost_delay","default_value":"0","hot_configurable":true,"description":"Vacuum + cost delay in milliseconds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":100},{"name":"vacuum_cost_page_hit","default_value":"1","hot_configurable":true,"description":"Vacuum + cost for a page found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_miss","default_value":"10","hot_configurable":true,"description":"Vacuum + cost for a page not found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_dirty","default_value":"20","hot_configurable":true,"description":"Vacuum + cost for a page dirtied by vacuum.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_limit","default_value":"200","hot_configurable":true,"description":"Vacuum + cost amount available before napping.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"bgwriter_delay","default_value":"200","hot_configurable":true,"description":"Background + writer sleep time between rounds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":10,"int_max":10000},{"name":"bgwriter_lru_maxpages","default_value":"100","hot_configurable":true,"description":"Background + writer maximum number of LRU pages to flush per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1073741823},{"name":"bgwriter_lru_multiplier","default_value":"2","hot_configurable":true,"description":"Multiple + of the average buffer usage to free per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10},{"name":"bgwriter_flush_after","default_value":"512","hot_configurable":true,"description":"Number + of pages after which previously performed writes are flushed to disk.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":0,"int_max":2048}],"disabled":false,"beta":false},{"version":"10","name":"PostgreSQL-10","end_of_life":"2022-11-10T00:00:00Z","available_settings":[{"name":"commit_delay","default_value":"0","hot_configurable":true,"description":"Sets + the delay in microseconds between transaction commit and flushing WAL to disk.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":100000},{"name":"tcp_keepalives_interval","default_value":"0","hot_configurable":true,"description":"Time + between TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"lock_timeout","default_value":"0","hot_configurable":false,"description":"Sets + the maximum allowed duration of any wait for a lock.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"default_statistics_target","default_value":"100","hot_configurable":true,"description":"Sets + the default statistics target.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"max_locks_per_transaction","default_value":"64","hot_configurable":false,"description":"Sets + the maximum number of locks per transaction.","property_type":"INT","unit":null,"string_constraint":null,"int_min":10,"int_max":2147483647},{"name":"temp_buffers","default_value":"8192","hot_configurable":true,"description":"Sets + the maximum number of temporary buffers used by each session.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":800,"int_max":1073741824},{"name":"idle_in_transaction_session_timeout","default_value":"3600000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any idling transaction. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"maintenance_work_mem","default_value":"64","hot_configurable":true,"description":"Sets + the maximum memory to be used for maintenance operations.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"max_connections","default_value":"100","hot_configurable":false,"description":"Sets + the maximum number of concurrent connections.","property_type":"INT","unit":null,"string_constraint":null,"int_min":50,"int_max":10000},{"name":"default_transaction_deferrable","default_value":"off","hot_configurable":true,"description":"Sets + the default deferrable status of new transactions.","property_type":"BOOLEAN","unit":null,"string_constraint":null,"int_min":null,"int_max":null},{"name":"work_mem","default_value":"4","hot_configurable":true,"description":"Sets + the maximum memory to be used for query workspaces.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"statement_timeout","default_value":"86400000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any statement. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":30000,"int_max":2147483647},{"name":"tcp_keepalives_count","default_value":"0","hot_configurable":true,"description":"Maximum + number of TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"tcp_keepalives_idle","default_value":"0","hot_configurable":true,"description":"Time + between issuing TCP keepalives.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"deadlock_timeout","default_value":"1000","hot_configurable":true,"description":"Sets + the time to wait on a lock before checking for deadlock.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":100,"int_max":60000},{"name":"max_parallel_workers","default_value":"8","hot_configurable":true,"description":"Sets + the maximum number of parallel workers that can be active at one time.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"effective_cache_size","default_value":"4096","hot_configurable":true,"description":"Sets + the planner s assumption about the size of the data cache.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":64,"int_max":1048576},{"name":"max_parallel_workers_per_gather","default_value":"2","hot_configurable":true,"description":"Sets + the maximum number of parallel processes per executor node.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"vacuum_cost_delay","default_value":"0","hot_configurable":true,"description":"Vacuum + cost delay in milliseconds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":100},{"name":"vacuum_cost_page_hit","default_value":"1","hot_configurable":true,"description":"Vacuum + cost for a page found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_miss","default_value":"10","hot_configurable":true,"description":"Vacuum + cost for a page not found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_dirty","default_value":"20","hot_configurable":true,"description":"Vacuum + cost for a page dirtied by vacuum.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_limit","default_value":"200","hot_configurable":true,"description":"Vacuum + cost amount available before napping.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"bgwriter_delay","default_value":"200","hot_configurable":true,"description":"Background + writer sleep time between rounds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":10,"int_max":10000},{"name":"bgwriter_lru_maxpages","default_value":"100","hot_configurable":true,"description":"Background + writer maximum number of LRU pages to flush per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1073741823},{"name":"bgwriter_lru_multiplier","default_value":"2","hot_configurable":true,"description":"Multiple + of the average buffer usage to free per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10},{"name":"bgwriter_flush_after","default_value":"512","hot_configurable":true,"description":"Number + of pages after which previously performed writes are flushed to disk.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":0,"int_max":2048},{"name":"temp_file_limit","default_value":"-1","hot_configurable":false,"description":"Limits + the total size of all temporary files used by each session.","property_type":"INT","unit":null,"string_constraint":null,"int_min":-1,"int_max":2147483647}],"disabled":false,"beta":false},{"version":"9.6","name":"PostgreSQL-9.6","end_of_life":"2021-11-11T00:00:00Z","available_settings":[{"name":"vacuum_cost_page_dirty","default_value":"20","hot_configurable":true,"description":"Vacuum + cost for a page dirtied by vacuum.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_limit","default_value":"200","hot_configurable":true,"description":"Vacuum + cost amount available before napping.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"bgwriter_delay","default_value":"200","hot_configurable":true,"description":"Background + writer sleep time between rounds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":10,"int_max":10000},{"name":"bgwriter_lru_maxpages","default_value":"100","hot_configurable":true,"description":"Background + writer maximum number of LRU pages to flush per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1073741823},{"name":"bgwriter_lru_multiplier","default_value":"2","hot_configurable":true,"description":"Multiple + of the average buffer usage to free per round.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10},{"name":"bgwriter_flush_after","default_value":"512","hot_configurable":true,"description":"Number + of pages after which previously performed writes are flushed to disk.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":0,"int_max":2048},{"name":"max_locks_per_transaction","default_value":"64","hot_configurable":false,"description":"Sets + the maximum number of locks per transaction.","property_type":"INT","unit":null,"string_constraint":null,"int_min":10,"int_max":2147483647},{"name":"idle_in_transaction_session_timeout","default_value":"3600000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any idling transaction. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"tcp_keepalives_interval","default_value":"0","hot_configurable":true,"description":"Time + between TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"lock_timeout","default_value":"0","hot_configurable":false,"description":"Sets + the maximum allowed duration of any wait for a lock.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"maintenance_work_mem","default_value":"64","hot_configurable":true,"description":"Sets + the maximum memory to be used for maintenance operations.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"default_transaction_deferrable","default_value":"off","hot_configurable":true,"description":"Sets + the default deferrable status of new transactions.","property_type":"BOOLEAN","unit":null,"string_constraint":null,"int_min":null,"int_max":null},{"name":"temp_file_limit","default_value":"-1","hot_configurable":false,"description":"Limits + the total size of all temporary files used by each session.","property_type":"INT","unit":null,"string_constraint":null,"int_min":-1,"int_max":2147483647},{"name":"tcp_keepalives_idle","default_value":"0","hot_configurable":true,"description":"Time + between issuing TCP keepalives.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"max_connections","default_value":"100","hot_configurable":false,"description":"Sets + the maximum number of concurrent connections.","property_type":"INT","unit":null,"string_constraint":null,"int_min":50,"int_max":10000},{"name":"work_mem","default_value":"4","hot_configurable":true,"description":"Sets + the maximum memory to be used for query workspaces.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":1,"int_max":2097151},{"name":"commit_delay","default_value":"0","hot_configurable":true,"description":"Sets + the delay in microseconds between transaction commit and flushing WAL to disk.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":100000},{"name":"tcp_keepalives_count","default_value":"0","hot_configurable":true,"description":"Maximum + number of TCP keepalive retransmits.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":2147483647},{"name":"statement_timeout","default_value":"86400000","hot_configurable":true,"description":"Sets + the maximum allowed duration of any statement. Value in ms","property_type":"INT","unit":"ms","string_constraint":null,"int_min":30000,"int_max":2147483647},{"name":"deadlock_timeout","default_value":"1000","hot_configurable":true,"description":"Sets + the time to wait on a lock before checking for deadlock.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":100,"int_max":60000},{"name":"effective_cache_size","default_value":"4096","hot_configurable":true,"description":"Sets + the planner s assumption about the size of the data cache.","property_type":"INT","unit":"MB","string_constraint":null,"int_min":64,"int_max":1048576},{"name":"max_parallel_workers_per_gather","default_value":"2","hot_configurable":true,"description":"Sets + the maximum number of parallel processes per executor node.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":1024},{"name":"vacuum_cost_delay","default_value":"0","hot_configurable":true,"description":"Vacuum + cost delay in milliseconds.","property_type":"INT","unit":"ms","string_constraint":null,"int_min":0,"int_max":100},{"name":"vacuum_cost_page_hit","default_value":"1","hot_configurable":true,"description":"Vacuum + cost for a page found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"vacuum_cost_page_miss","default_value":"10","hot_configurable":true,"description":"Vacuum + cost for a page not found in the buffer cache.","property_type":"INT","unit":null,"string_constraint":null,"int_min":0,"int_max":10000},{"name":"default_statistics_target","default_value":"100","hot_configurable":true,"description":"Sets + the default statistics target.","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":10000},{"name":"temp_buffers","default_value":"8192","hot_configurable":true,"description":"Sets + the maximum number of temporary buffers used by each session.","property_type":"INT","unit":"kB","string_constraint":null,"int_min":800,"int_max":1073741824}],"disabled":false,"beta":false}],"region":"fr-par"},{"name":"MySQL","logo_url":"https://s3.nl-ams.scw.cloud/scw-rdb-logos/mysql.svg","versions":[{"version":"8","name":"MySQL-8","end_of_life":"2026-04-01T00:00:00Z","available_settings":[{"name":"default_authentication_plugin","default_value":"mysql_native_password","hot_configurable":false,"description":"The + default authentication plugin at the user creation","property_type":"STRING","unit":null,"string_constraint":"^(mysql_native_password|caching_sha2_password)$","int_min":null,"int_max":null},{"name":"innodb_lock_wait_timeout","default_value":"50","hot_configurable":true,"description":"The + length of time in seconds an InnoDB transaction waits for a row lock before + giving up","property_type":"INT","unit":null,"string_constraint":null,"int_min":1,"int_max":600},{"name":"lock_wait_timeout","default_value":"31536000","hot_configurable":true,"description":"This + variable specifies the timeout in seconds for attempts to acquire metadata locks","property_type":"INT","unit":null,"string_constraint":null,"int_min":60,"int_max":31536000},{"name":"log_bin_trust_function_creators","default_value":"OFF","hot_configurable":true,"description":"This + variable controls whether stored function creators can be trusted","property_type":"BOOLEAN","unit":null,"string_constraint":null,"int_min":null,"int_max":null},{"name":"innodb_stats_persistent_sample_pages","default_value":"200","hot_configurable":true,"description":"The + number of index pages to sample when estimating cardinality and other statistics + for an indexed column","property_type":"INT","unit":null,"string_constraint":null,"int_min":20,"int_max":1000},{"name":"interactive_timeout","default_value":"21600","hot_configurable":true,"description":"The + number of seconds the server waits for activity on an interactive connection + before closing it","property_type":"INT","unit":null,"string_constraint":null,"int_min":60,"int_max":21600},{"name":"max_allowed_packet","default_value":"64","hot_configurable":true,"description":"The + maximum size (MB) of one packet or any generated/intermediate string, or any + parameter sent by the mysql_stmt_send_long_data() C API function","property_type":"INT","unit":"M","string_constraint":null,"int_min":4,"int_max":1024},{"name":"max_connections","default_value":"100","hot_configurable":true,"description":"The + maximum permitted number of simultaneous client connections","property_type":"INT","unit":null,"string_constraint":null,"int_min":50,"int_max":5000},{"name":"sql_mode","default_value":"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","hot_configurable":true,"description":"Modes + affect the SQL syntax MySQL supports and the data validation checks it performs","property_type":"STRING","unit":null,"string_constraint":"^((ONLY_FULL_GROUP_BY|STRICT_TRANS_TABLES|NO_ZERO_IN_DATE|NO_ZERO_DATE|ERROR_FOR_DIVISION_BY_ZERO|NO_ENGINE_SUBSTITUTION)(,(ONLY_FULL_GROUP_BY|STRICT_TRANS_TABLES|NO_ZERO_IN_DATE|NO_ZERO_DATE|ERROR_FOR_DIVISION_BY_ZERO|NO_ENGINE_SUBSTITUTION))*)?$","int_min":null,"int_max":null},{"name":"table_open_cache","default_value":"10000","hot_configurable":true,"description":"table_open_cache","property_type":"INT","unit":null,"string_constraint":null,"int_min":1000,"int_max":20000},{"name":"wait_timeout","default_value":"21600","hot_configurable":false,"description":"The + number of seconds the server waits for activity on a noninteractive connection + before closing it","property_type":"INT","unit":null,"string_constraint":null,"int_min":60,"int_max":21600}],"disabled":false,"beta":false}],"region":"fr-par"}],"total_count":2}' + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 06 Jul 2020 09:47:46 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 300bf3fa-7acf-4b57-bf83-0d4bb2719e9b + status: 200 OK + code: 200 + duration: "" diff --git a/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden new file mode 100644 index 0000000000..d604b46a78 --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden @@ -0,0 +1,36 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Name Engine Type End of Life +PostgreSQL-12 PostgreSQL few seconds ago +PostgreSQL-11 PostgreSQL few seconds ago +PostgreSQL-10 PostgreSQL few seconds ago +PostgreSQL-9.6 PostgreSQL few seconds ago +MySQL-8 MySQL few seconds ago +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +[ + { + "Name": "PostgreSQL-12", + "EngineType": "PostgreSQL", + "EndOfLife": "2024-11-14T00:00:00Z" + }, + { + "Name": "PostgreSQL-11", + "EngineType": "PostgreSQL", + "EndOfLife": "2023-11-09T00:00:00Z" + }, + { + "Name": "PostgreSQL-10", + "EngineType": "PostgreSQL", + "EndOfLife": "2022-11-10T00:00:00Z" + }, + { + "Name": "PostgreSQL-9.6", + "EngineType": "PostgreSQL", + "EndOfLife": "2021-11-11T00:00:00Z" + }, + { + "Name": "MySQL-8", + "EngineType": "MySQL", + "EndOfLife": "2026-04-01T00:00:00Z" + } +] From 8866bdff9f2551e8f9a774b7180ab9cf6ef4f1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 6 Jul 2020 11:49:45 +0200 Subject: [PATCH 3/6] Fix --- internal/namespaces/rdb/v1/custom_engine_list_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/namespaces/rdb/v1/custom_engine_list_test.go b/internal/namespaces/rdb/v1/custom_engine_list_test.go index 5c82026fb5..e107ad3f06 100644 --- a/internal/namespaces/rdb/v1/custom_engine_list_test.go +++ b/internal/namespaces/rdb/v1/custom_engine_list_test.go @@ -12,7 +12,6 @@ func Test_EngineList(t *testing.T) { Cmd: "scw rdb engine list", Check: core.TestCheckCombine( core.TestCheckGolden(), - core.TestCheckExitCode(0), ), })) } From d8417fe19705c670c672058c0828478e8ab424a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 6 Jul 2020 11:52:24 +0200 Subject: [PATCH 4/6] Fix --- internal/namespaces/rdb/v1/custom_engine_list_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/namespaces/rdb/v1/custom_engine_list_test.go b/internal/namespaces/rdb/v1/custom_engine_list_test.go index e107ad3f06..4b0c7e7b56 100644 --- a/internal/namespaces/rdb/v1/custom_engine_list_test.go +++ b/internal/namespaces/rdb/v1/custom_engine_list_test.go @@ -10,8 +10,6 @@ func Test_EngineList(t *testing.T) { t.Run("Simple", core.Test(&core.TestConfig{ Commands: GetCommands(), Cmd: "scw rdb engine list", - Check: core.TestCheckCombine( - core.TestCheckGolden(), - ), + Check: core.TestCheckGolden(), })) } From 9b152aa3314c49f48afbab8b99e4aea422ced3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 7 Jul 2020 11:03:52 +0200 Subject: [PATCH 5/6] Fix --- internal/namespaces/rdb/v1/custom_engine_list.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/namespaces/rdb/v1/custom_engine_list.go b/internal/namespaces/rdb/v1/custom_engine_list.go index 3d00778dbf..fc34222305 100644 --- a/internal/namespaces/rdb/v1/custom_engine_list.go +++ b/internal/namespaces/rdb/v1/custom_engine_list.go @@ -9,10 +9,10 @@ import ( ) func engineListBuilder(c *core.Command) *core.Command { - type customList struct { - Name string - EngineType string - EndOfLife time.Time + type customEngine struct { + Name string `json:"name"` + EngineType string `json:"engine_type"` + EndOfLife time.Time `json:"end_of_life"` } c.View = &core.View{ @@ -38,10 +38,10 @@ func engineListBuilder(c *core.Command) *core.Command { return listEngineResp, err } engineList := listEngineResp.([]*rdb.DatabaseEngine) - var res []customList + var res []customEngine for _, engine := range engineList { for _, version := range engine.Versions { - res = append(res, customList{ + res = append(res, customEngine{ Name: version.Name, EngineType: engine.Name, EndOfLife: version.EndOfLife, From 0a456b59b9e73121b9cce76cc8d96bd2fa6b57ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 7 Jul 2020 11:16:29 +0200 Subject: [PATCH 6/6] Fix --- .../testdata/test-engine-list-simple.golden | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden index d604b46a78..6c833fc2e1 100644 --- a/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden +++ b/internal/namespaces/rdb/v1/testdata/test-engine-list-simple.golden @@ -9,28 +9,28 @@ MySQL-8 MySQL few seconds ago 🟩🟩🟩 JSON STDOUT 🟩🟩🟩 [ { - "Name": "PostgreSQL-12", - "EngineType": "PostgreSQL", - "EndOfLife": "2024-11-14T00:00:00Z" + "name": "PostgreSQL-12", + "engine_type": "PostgreSQL", + "end_of_life": "2024-11-14T00:00:00Z" }, { - "Name": "PostgreSQL-11", - "EngineType": "PostgreSQL", - "EndOfLife": "2023-11-09T00:00:00Z" + "name": "PostgreSQL-11", + "engine_type": "PostgreSQL", + "end_of_life": "2023-11-09T00:00:00Z" }, { - "Name": "PostgreSQL-10", - "EngineType": "PostgreSQL", - "EndOfLife": "2022-11-10T00:00:00Z" + "name": "PostgreSQL-10", + "engine_type": "PostgreSQL", + "end_of_life": "2022-11-10T00:00:00Z" }, { - "Name": "PostgreSQL-9.6", - "EngineType": "PostgreSQL", - "EndOfLife": "2021-11-11T00:00:00Z" + "name": "PostgreSQL-9.6", + "engine_type": "PostgreSQL", + "end_of_life": "2021-11-11T00:00:00Z" }, { - "Name": "MySQL-8", - "EngineType": "MySQL", - "EndOfLife": "2026-04-01T00:00:00Z" + "name": "MySQL-8", + "engine_type": "MySQL", + "end_of_life": "2026-04-01T00:00:00Z" } ]