From 870da04e97ff29cc0cf8e1e973460b376756773e Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Thu, 28 Mar 2019 16:40:05 +0800 Subject: [PATCH 1/4] Add Authentication option for CCE cluster --- openstack/cce/v3/clusters/results.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openstack/cce/v3/clusters/results.go b/openstack/cce/v3/clusters/results.go index 629451ae2..024e29cd8 100644 --- a/openstack/cce/v3/clusters/results.go +++ b/openstack/cce/v3/clusters/results.go @@ -54,6 +54,8 @@ type Spec struct { HostNetwork HostNetworkSpec `json:"hostNetwork" required:"true"` //Container network parameters ContainerNetwork ContainerNetworkSpec `json:"containerNetwork" required:"true"` + //Authentication parameters + Authentication AuthenticationSpec `json:"authentication,omitempty"` // Charging mode of the cluster, which is 0 (on demand) BillingMode int `json:"billingMode,omitempty"` //Extended parameter for a cluster @@ -79,6 +81,13 @@ type ContainerNetworkSpec struct { Cidr string `json:"cidr,omitempty"` } +//Authentication parameters +type AuthenticationSpec struct { + //Authentication mode: rbac , x509 or authenticating_proxy + Mode string `json:"mode" required:"true"` + AuthenticatingProxy map[string]string `json:"authenticatingProxy" required:"true"` +} + type Status struct { //The state of the cluster Phase string `json:"phase"` From ab6635dd89283068d6471ca583da4d6705e53f97 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Thu, 28 Mar 2019 20:26:06 +0800 Subject: [PATCH 2/4] Fix tests --- openstack/cce/v3/clusters/results.go | 2 +- openstack/cce/v3/clusters/testing/requests_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openstack/cce/v3/clusters/results.go b/openstack/cce/v3/clusters/results.go index 024e29cd8..530dc4cbd 100644 --- a/openstack/cce/v3/clusters/results.go +++ b/openstack/cce/v3/clusters/results.go @@ -84,7 +84,7 @@ type ContainerNetworkSpec struct { //Authentication parameters type AuthenticationSpec struct { //Authentication mode: rbac , x509 or authenticating_proxy - Mode string `json:"mode" required:"true"` + Mode string `json:"mode" required:"true"` AuthenticatingProxy map[string]string `json:"authenticatingProxy" required:"true"` } diff --git a/openstack/cce/v3/clusters/testing/requests_test.go b/openstack/cce/v3/clusters/testing/requests_test.go index 8cc22b551..0b9693f90 100644 --- a/openstack/cce/v3/clusters/testing/requests_test.go +++ b/openstack/cce/v3/clusters/testing/requests_test.go @@ -130,6 +130,10 @@ func TestCreateV3Cluster(t *testing.T) { "containerNetwork": { "mode": "overlay_l2" } + "authentication": { + "mode": "rbac", + "authenticatingProxy": {} + } } } @@ -149,6 +153,9 @@ func TestCreateV3Cluster(t *testing.T) { VpcId: "3305eb40-2707-4940-921c-9f335f84a2ca", SubnetId: "00e41db7-e56b-4946-bf91-27bb9effd664"}, ContainerNetwork: clusters.ContainerNetworkSpec{Mode: "overlay_l2"}, + Authentication: clusters.AuthenticationSpec{ + Mode: "rbac", + AuthenticatingProxy: make(map[string]string)} }, } actual, err := clusters.Create(fake.ServiceClient(), options).Extract() From d3518186ea05299ec19522783b233f0794841cff Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Fri, 29 Mar 2019 09:13:47 +0800 Subject: [PATCH 3/4] Fix literal error --- openstack/cce/v3/clusters/testing/requests_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstack/cce/v3/clusters/testing/requests_test.go b/openstack/cce/v3/clusters/testing/requests_test.go index 0b9693f90..cae889753 100644 --- a/openstack/cce/v3/clusters/testing/requests_test.go +++ b/openstack/cce/v3/clusters/testing/requests_test.go @@ -155,7 +155,7 @@ func TestCreateV3Cluster(t *testing.T) { ContainerNetwork: clusters.ContainerNetworkSpec{Mode: "overlay_l2"}, Authentication: clusters.AuthenticationSpec{ Mode: "rbac", - AuthenticatingProxy: make(map[string]string)} + AuthenticatingProxy: make(map[string]string)}, }, } actual, err := clusters.Create(fake.ServiceClient(), options).Extract() From ae306856d08661fb675c233e0af874b5901004c7 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Fri, 29 Mar 2019 09:34:34 +0800 Subject: [PATCH 4/4] Fix coverage --- openstack/cce/v3/clusters/testing/requests_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openstack/cce/v3/clusters/testing/requests_test.go b/openstack/cce/v3/clusters/testing/requests_test.go index cae889753..acd4639e0 100644 --- a/openstack/cce/v3/clusters/testing/requests_test.go +++ b/openstack/cce/v3/clusters/testing/requests_test.go @@ -129,7 +129,7 @@ func TestCreateV3Cluster(t *testing.T) { }, "containerNetwork": { "mode": "overlay_l2" - } + }, "authentication": { "mode": "rbac", "authenticatingProxy": {} @@ -154,7 +154,7 @@ func TestCreateV3Cluster(t *testing.T) { SubnetId: "00e41db7-e56b-4946-bf91-27bb9effd664"}, ContainerNetwork: clusters.ContainerNetworkSpec{Mode: "overlay_l2"}, Authentication: clusters.AuthenticationSpec{ - Mode: "rbac", + Mode: "rbac", AuthenticatingProxy: make(map[string]string)}, }, }