From 501f2be96928e6cf959880c9680a81362c3ee4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 10 Jul 2020 11:48:10 +0200 Subject: [PATCH 1/5] feat(k8s): improve human marshaller for cluster --- internal/namespaces/k8s/v1/custom.go | 1 + internal/namespaces/k8s/v1/custom_cluster.go | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/internal/namespaces/k8s/v1/custom.go b/internal/namespaces/k8s/v1/custom.go index 6edbda6a5a..2d92908aaa 100644 --- a/internal/namespaces/k8s/v1/custom.go +++ b/internal/namespaces/k8s/v1/custom.go @@ -24,6 +24,7 @@ func GetCommands() *core.Commands { k8sPoolWaitCommand(), )) + human.RegisterMarshalerFunc(k8s.Cluster{}, clusterMarshalerFunc) human.RegisterMarshalerFunc(k8s.ClusterStatus(0), human.EnumMarshalFunc(clusterStatusMarshalSpecs)) human.RegisterMarshalerFunc(k8s.PoolStatus(0), human.EnumMarshalFunc(poolStatusMarshalSpecs)) human.RegisterMarshalerFunc(k8s.NodeStatus(0), human.EnumMarshalFunc(nodeStatusMarshalSpecs)) diff --git a/internal/namespaces/k8s/v1/custom_cluster.go b/internal/namespaces/k8s/v1/custom_cluster.go index 36723f8bef..c1f1dcf2f0 100644 --- a/internal/namespaces/k8s/v1/custom_cluster.go +++ b/internal/namespaces/k8s/v1/custom_cluster.go @@ -41,6 +41,30 @@ const ( clusterActionDelete ) +func clusterMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) { + type tmp k8s.Cluster + cluster := tmp(i.(k8s.Cluster)) + + // Sections + opt.Sections = []*human.MarshalSection{ + { + FieldName: "AutoscalerConfig", + Title: "Auto-scaler configuration", + }, + { + FieldName: "AutoUpgrade", + Title: "Auto-upgrade settings", + }, + } + + str, err := human.Marshal(cluster, opt) + if err != nil { + return "", err + } + + return str, nil +} + func clusterAvailableVersionsListBuilder(c *core.Command) *core.Command { c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) { originalRes, err := runner(ctx, argsI) From c02d5e30e396277c148ad9f8f2594af6a7eaca2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 10 Jul 2020 13:22:19 +0200 Subject: [PATCH 2/5] Update internal/namespaces/k8s/v1/custom_cluster.go Co-authored-by: Patrik --- internal/namespaces/k8s/v1/custom_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/namespaces/k8s/v1/custom_cluster.go b/internal/namespaces/k8s/v1/custom_cluster.go index c1f1dcf2f0..907ab4c0bf 100644 --- a/internal/namespaces/k8s/v1/custom_cluster.go +++ b/internal/namespaces/k8s/v1/custom_cluster.go @@ -49,7 +49,7 @@ func clusterMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) opt.Sections = []*human.MarshalSection{ { FieldName: "AutoscalerConfig", - Title: "Auto-scaler configuration", + Title: "Autoscaler configuration", }, { FieldName: "AutoUpgrade", From 76715ec670eecabca9970665da59653d190fb89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 10 Jul 2020 13:47:39 +0200 Subject: [PATCH 3/5] Fix --- .../namespaces/k8s/v1/custom_cluster_test.go | 20 +++++++++++++++++++ internal/namespaces/k8s/v1/helpers_test.go | 15 ++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 internal/namespaces/k8s/v1/custom_cluster_test.go diff --git a/internal/namespaces/k8s/v1/custom_cluster_test.go b/internal/namespaces/k8s/v1/custom_cluster_test.go new file mode 100644 index 0000000000..9d33d705f1 --- /dev/null +++ b/internal/namespaces/k8s/v1/custom_cluster_test.go @@ -0,0 +1,20 @@ +package k8s + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/internal/core" +) + +func Test_WaitCluster(t *testing.T) { + t.Run("wait for pools", core.Test(&core.TestConfig{ + Commands: GetCommands(), + BeforeFunc: createCluster("Cluster", kapsuleVersion, 3), + Cmd: "scw k8s cluster wait {{ .Cluster.ID }} wait-for-pools=true", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + AfterFunc: deleteCluster("Cluster"), + })) +} diff --git a/internal/namespaces/k8s/v1/helpers_test.go b/internal/namespaces/k8s/v1/helpers_test.go index 08f1c35619..e7f5577397 100644 --- a/internal/namespaces/k8s/v1/helpers_test.go +++ b/internal/namespaces/k8s/v1/helpers_test.go @@ -17,6 +17,17 @@ const ( // Clusters // +// createCluster creates a basic cluster with "poolSize" dev1-m as nodes, the given version and +// register it in the context Meta at metaKey. +func createCluster(metaKey string, version string, poolSize int) core.BeforeFunc { + return func(ctx *core.BeforeFuncCtx) error { + core.ExecStoreBeforeCmd( + metaKey, + fmt.Sprintf("scw k8s cluster create name=cli-test version=%s cni=cilium pools.0.node-type=DEV1-M pools.0.size=%d pools.0.name=default --wait", version, poolSize)) + return nil + } +} + // createClusterAndWaitAndKubeconfig creates a basic cluster with 1 dev1-m as node, the given version and // register it in the context Meta at metaKey. func createClusterAndWaitAndKubeconfig(metaKey string, kubeconfigMetaKey string, version string) core.BeforeFunc { @@ -115,3 +126,7 @@ func createClusterAndWaitAndKubeconfigAndPopulateFileAndInstall(metaKey string, func deleteCluster(metaKey string) core.AfterFunc { return core.ExecAfterCmd("scw k8s cluster delete {{ ." + metaKey + ".ID }} --wait") } + +func createCluster(metaKey string) core.AfterFunc { + return core.ExecAfterCmd("scw k8s cluster delete {{ ." + metaKey + ".ID }} --wait") +} From 4bfc219daff58443ab28072ab50f1864e7d15218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 10 Jul 2020 14:01:19 +0200 Subject: [PATCH 4/5] Fix --- .../namespaces/k8s/v1/custom_cluster_test.go | 8 +- internal/namespaces/k8s/v1/helpers_test.go | 13 +- .../test-get-cluster-simple.cassette.yaml | 357 ++++++++++++++++++ .../testdata/test-get-cluster-simple.golden | 70 ++++ 4 files changed, 434 insertions(+), 14 deletions(-) create mode 100644 internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.cassette.yaml create mode 100644 internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden diff --git a/internal/namespaces/k8s/v1/custom_cluster_test.go b/internal/namespaces/k8s/v1/custom_cluster_test.go index 9d33d705f1..faa13bcb9e 100644 --- a/internal/namespaces/k8s/v1/custom_cluster_test.go +++ b/internal/namespaces/k8s/v1/custom_cluster_test.go @@ -6,11 +6,11 @@ import ( "github.com/scaleway/scaleway-cli/internal/core" ) -func Test_WaitCluster(t *testing.T) { - t.Run("wait for pools", core.Test(&core.TestConfig{ +func Test_GetCluster(t *testing.T) { + t.Run("Simple", core.Test(&core.TestConfig{ Commands: GetCommands(), - BeforeFunc: createCluster("Cluster", kapsuleVersion, 3), - Cmd: "scw k8s cluster wait {{ .Cluster.ID }} wait-for-pools=true", + BeforeFunc: createCluster("Cluster", kapsuleVersion, 1), + Cmd: "scw k8s cluster get {{ .Cluster.ID }}", Check: core.TestCheckCombine( core.TestCheckGolden(), core.TestCheckExitCode(0), diff --git a/internal/namespaces/k8s/v1/helpers_test.go b/internal/namespaces/k8s/v1/helpers_test.go index e7f5577397..7086ba5d60 100644 --- a/internal/namespaces/k8s/v1/helpers_test.go +++ b/internal/namespaces/k8s/v1/helpers_test.go @@ -20,12 +20,9 @@ const ( // createCluster creates a basic cluster with "poolSize" dev1-m as nodes, the given version and // register it in the context Meta at metaKey. func createCluster(metaKey string, version string, poolSize int) core.BeforeFunc { - return func(ctx *core.BeforeFuncCtx) error { - core.ExecStoreBeforeCmd( - metaKey, - fmt.Sprintf("scw k8s cluster create name=cli-test version=%s cni=cilium pools.0.node-type=DEV1-M pools.0.size=%d pools.0.name=default --wait", version, poolSize)) - return nil - } + return core.ExecStoreBeforeCmd( + metaKey, + fmt.Sprintf("scw k8s cluster create name=cli-test version=%s cni=cilium pools.0.node-type=DEV1-M pools.0.size=%d pools.0.name=default", version, poolSize)) } // createClusterAndWaitAndKubeconfig creates a basic cluster with 1 dev1-m as node, the given version and @@ -126,7 +123,3 @@ func createClusterAndWaitAndKubeconfigAndPopulateFileAndInstall(metaKey string, func deleteCluster(metaKey string) core.AfterFunc { return core.ExecAfterCmd("scw k8s cluster delete {{ ." + metaKey + ".ID }} --wait") } - -func createCluster(metaKey string) core.AfterFunc { - return core.ExecAfterCmd("scw k8s cluster delete {{ ." + metaKey + ".ID }} --wait") -} diff --git a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.cassette.yaml b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.cassette.yaml new file mode 100644 index 0000000000..f1f6b90ef6 --- /dev/null +++ b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.cassette.yaml @@ -0,0 +1,357 @@ +--- +version: 1 +interactions: +- request: + body: '{"organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"cli-test","description":"","tags":null,"version":"1.17.3","cni":"cilium","enable_dashboard":false,"ingress":"unknown_ingress","pools":[{"name":"default","node_type":"DEV1-M","placement_group_id":null,"autoscaling":false,"size":1,"min_size":null,"max_size":null,"container_runtime":"unknown_runtime","autohealing":false,"tags":null}],"autoscaler_config":null,"auto_upgrade":null,"feature_gates":null,"admission_plugins":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/k8s/v1/regions/fr-par/clusters + method: POST + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358305Z","updated_at":"2020-07-10T11:55:04.486358305Z","name":"cli-test","description":"","status":"creating","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":false,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "954" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:05 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3ddd5ae4-4794-4d96-9f66-8ae14deccdc5 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:04.486358Z","name":"cli-test","description":"","status":"creating","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:05 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 9ea82c8e-66a1-41c4-bd0c-3bc445da34f7 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb?with_additional_resources=false + method: DELETE + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737330821Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "950" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:05 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ca5344ce-9d05-40a0-ab09-66c19f395ce7 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:05 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 2917f163-a25e-4f7c-b886-27d3edd1c449 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:10 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 80ac4903-3a1e-44e0-a6b2-e1ffaf07e02d + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:15 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 69c704b1-512e-4a75-a1bb-7c2cf1f43a19 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:20 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - bab03186-6af3-4751-8978-9dc8b7693c58 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:25 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b6204333-9e9f-49a0-8757-b404e891ce0c + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:30 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c27c614c-cd93-4b56-a886-6f1b8d66df91 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"region":"fr-par","id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","created_at":"2020-07-10T11:55:04.486358Z","updated_at":"2020-07-10T11:55:05.737331Z","name":"cli-test","description":"","status":"deleting","version":"1.17.3","cni":"cilium","tags":[],"cluster_url":"https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443","dns_wildcard":"*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud","autoscaler_config":{"scale_down_disabled":false,"scale_down_delay_after_add":"10m","estimator":"binpacking","expander":"random","ignore_daemonsets_utilization":false,"balance_similar_node_groups":false,"expendable_pods_priority_cutoff":-10,"scale_down_unneeded_time":"10m"},"dashboard_enabled":false,"ingress":"none","auto_upgrade":{"enabled":false,"maintenance_window":{"start_hour":0,"day":"any"}},"upgrade_available":true,"feature_gates":[],"admission_plugins":[]}' + headers: + Content-Length: + - "947" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:35 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 09b5964d-56d6-49bf-b4ff-8c122ee1cf64 + 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/k8s/v1/regions/fr-par/clusters/000ffe06-a10a-4f2a-8e06-0d64c7908fdb + method: GET + response: + body: '{"message":"resource is not found","resource":"cluster","resource_id":"000ffe06-a10a-4f2a-8e06-0d64c7908fdb","type":"not_found"}' + headers: + Content-Length: + - "128" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Fri, 10 Jul 2020 11:55:40 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 729ef53a-7a49-49b1-a08e-a627008dc4c1 + status: 404 Not Found + code: 404 + duration: "" diff --git a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden new file mode 100644 index 0000000000..68f1af3bb7 --- /dev/null +++ b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden @@ -0,0 +1,70 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +ID 000ffe06-a10a-4f2a-8e06-0d64c7908fdb +Name cli-test +Status creating +Version 1.17.3 +Region fr-par +OrganizationID 951df375-e094-4d26-97c1-ba548eeb9c42 +Cni cilium +Description - +ClusterURL https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443 +DNSWildcard *.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud +CreatedAt few seconds ago +UpdatedAt few seconds ago +DashboardEnabled false +Ingress none +UpgradeAvailable true + +Auto-scaler configuration: +ScaleDownDisabled false +ScaleDownDelayAfterAdd 10m +Estimator binpacking +Expander random +IgnoreDaemonsetsUtilization false +BalanceSimilarNodeGroups false +ExpendablePodsPriorityCutoff -10 +ScaleDownUnneededTime 10m + +Auto-upgrade settings: +Enabled false +MaintenanceWindow.StartHour 0 +MaintenanceWindow.Day any +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "id": "000ffe06-a10a-4f2a-8e06-0d64c7908fdb", + "name": "cli-test", + "status": "creating", + "version": "1.17.3", + "region": "fr-par", + "organization_id": "951df375-e094-4d26-97c1-ba548eeb9c42", + "tags": [], + "cni": "cilium", + "description": "", + "cluster_url": "https://000ffe06-a10a-4f2a-8e06-0d64c7908fdb.api.k8s.fr-par.scw.cloud:6443", + "dns_wildcard": "*.000ffe06-a10a-4f2a-8e06-0d64c7908fdb.nodes.k8s.fr-par.scw.cloud", + "created_at": "1970-01-01T00:00:00.0Z", + "updated_at": "1970-01-01T00:00:00.0Z", + "autoscaler_config": { + "scale_down_disabled": false, + "scale_down_delay_after_add": "10m", + "estimator": "binpacking", + "expander": "random", + "ignore_daemonsets_utilization": false, + "balance_similar_node_groups": false, + "expendable_pods_priority_cutoff": -10, + "scale_down_unneeded_time": "10m" + }, + "dashboard_enabled": false, + "ingress": "none", + "auto_upgrade": { + "enabled": false, + "maintenance_window": { + "start_hour": 0, + "day": "any" + } + }, + "upgrade_available": true, + "feature_gates": [], + "admission_plugins": [] +} From 585cfae555efc37de3ee97bdf9399e68f1c6d7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 10 Jul 2020 14:02:24 +0200 Subject: [PATCH 5/5] Fix --- .../namespaces/k8s/v1/testdata/test-get-cluster-simple.golden | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden index 68f1af3bb7..046e0387a9 100644 --- a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden +++ b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden @@ -16,7 +16,7 @@ DashboardEnabled false Ingress none UpgradeAvailable true -Auto-scaler configuration: +Autoscaler configuration: ScaleDownDisabled false ScaleDownDelayAfterAdd 10m Estimator binpacking