Skip to content

Commit 08576c7

Browse files
authored
Merge pull request #42 from sykim-etri/add-suppots-api
Support GET /v1/supports API
2 parents 536bc37 + 1702247 commit 08576c7

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

openstack/containerinfra/v1/clusters/requests.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,10 @@ func GetConfig(client *gophercloud.ServiceClient, id string) (r ConfigResult) {
239239
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
240240
return
241241
}
242+
243+
// GetSupports retrieves a list of supported Kubernetes versions.
244+
func GetSupports(client *gophercloud.ServiceClient) (r SupportsResult) {
245+
resp, err := client.Get(supportsURL(client), &r.Body, &gophercloud.RequestOpts{OkCodes: []int{200}})
246+
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
247+
return
248+
}

openstack/containerinfra/v1/clusters/results.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ type ConfigResult struct {
5454
commonResult
5555
}
5656

57+
// SupportsResult is the response of a get supports operation.
58+
type SupportsResult struct {
59+
commonResult
60+
}
61+
5762
func (r CreateResult) Extract() (string, error) {
5863
var s struct {
5964
UUID string
@@ -94,6 +99,22 @@ func (r ConfigResult) Extract() (string, error) {
9499
return s.Config, err
95100
}
96101

102+
type Supports struct {
103+
SupportedK8s map[string]bool `json:"supported_k8s"`
104+
SupportedEventType EventType `json:"supported_event_type"`
105+
}
106+
107+
type EventType struct {
108+
ClusterEvents map[string]string `json:"cluster_events"`
109+
NodegroupEvents map[string]string `json:"nodegroup_events"`
110+
}
111+
112+
func (r SupportsResult) Extract() (*Supports, error) {
113+
var s Supports
114+
err := r.ExtractInto(&s)
115+
return &s, err
116+
}
117+
97118
type Cluster struct {
98119
APIAddress string `json:"api_address"`
99120
COEVersion string `json:"coe_version"` // COEVersion is sometimes not valid, especially after upgrading a cluster

openstack/containerinfra/v1/clusters/urls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ func resizeURL(client *gophercloud.ServiceClient, id string) string {
4949
func configURL(client *gophercloud.ServiceClient, id string) string {
5050
return client.ServiceURL("clusters", id, "config")
5151
}
52+
53+
func supportsURL(client *gophercloud.ServiceClient) string {
54+
return client.ServiceURL("supports")
55+
}

0 commit comments

Comments
 (0)