Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions openstack/cce/v3/clusters/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ func Get(c *golangsdk.ServiceClient, id string) (r GetResult) {
return
}

// GetCert retrieves a particular cluster certificate based on its unique ID.
func GetCert(c *golangsdk.ServiceClient, id string) (r GetCertResult) {
_, r.Err = c.Get(certificateURL(c, id), &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{200},
MoreHeaders: RequestOpts.MoreHeaders, JSONBody: nil,
})
return
}

// UpdateOpts contains all the values needed to update a new cluster
type UpdateOpts struct {
Spec UpdateSpec `json:"spec" required:"true"`
Expand Down
68 changes: 68 additions & 0 deletions openstack/cce/v3/clusters/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,63 @@ type Endpoints struct {
ExternalOTC string `json:"external_otc"`
}

type Certificate struct {
//API type, fixed value Config
Kind string `json:"kind"`
//API version, fixed value v1
ApiVersion string `json:"apiVersion"`
//Cluster list
Clusters []CertClusters `json:"clusters"`
//User list
Users []CertUsers `json:"users"`
//Context list
Contexts []CertContexts `json:"contexts"`
//The current context
CurrentContext string `json:"current-context"`
}

type CertClusters struct {
//Cluster name
Name string `json:"name"`
//Cluster information
Cluster CertCluster `json:"cluster"`
}

type CertCluster struct {
//Server IP address
Server string `json:"server"`
//Certificate data
CertAuthorityData string `json:"certificate-authority-data"`
}

type CertUsers struct {
//User name
Name string `json:"name"`
//Cluster information
User CertUser `json:"user"`
}

type CertUser struct {
//Client certificate
ClientCertData string `json:"client-certificate-data"`
//Client key data
ClientKeyData string `json:"client-key-data"`
}

type CertContexts struct {
//Context name
Name string `json:"name"`
//Context information
Context CertContext `json:"context"`
}

type CertContext struct {
//Cluster name
Cluster string `json:"cluster"`
//User name
User string `json:"user"`
}

// UnmarshalJSON helps to unmarshal Status fields into needed values.
//OTC and Huawei have different data types and child fields for `endpoints` field in Cluster Status.
//This function handles the unmarshal for both
Expand Down Expand Up @@ -215,3 +272,14 @@ type DeleteResult struct {
type ListResult struct {
commonResult
}

type GetCertResult struct {
golangsdk.Result
}

// Extract is a function that accepts a result and extracts a cluster.
func (r GetCertResult) Extract() (*Certificate, error) {
var s Certificate
err := r.ExtractInto(&s)
return &s, err
}
5 changes: 5 additions & 0 deletions openstack/cce/v3/clusters/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "github.com/huaweicloud/golangsdk"

const (
rootPath = "clusters"
certPath = "clustercert"
)

func rootURL(client *golangsdk.ServiceClient) string {
Expand All @@ -13,3 +14,7 @@ func rootURL(client *golangsdk.ServiceClient) string {
func resourceURL(c *golangsdk.ServiceClient, id string) string {
return c.ServiceURL(rootPath, id)
}

func certificateURL(c *golangsdk.ServiceClient, id string) string {
return c.ServiceURL(rootPath, id, certPath)
}