Skip to content

Commit e4c1b76

Browse files
authored
Support LKE tier version (#676)
* support tier * nit * nit * fmt
1 parent 1f1254b commit e4c1b76

File tree

3 files changed

+190
-0
lines changed

3 files changed

+190
-0
lines changed

lke_clusters.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ type LKEVersion struct {
8181
ID string `json:"id"`
8282
}
8383

84+
// LKETierVersion fields are those returned by GetLKETierVersion
85+
// NOTE: It may not currently be available to all users and can only be used with v4beta.
86+
type LKETierVersion struct {
87+
ID string `json:"id"`
88+
Tier LKEVersionTier `json:"tier"`
89+
}
90+
91+
// LKEVersionTier enums represents different LKE tiers
92+
type LKEVersionTier string
93+
94+
// LKEVersionTier enums start with LKEVersion
95+
const (
96+
LKEVersionStandard LKEVersionTier = "standard"
97+
LKEVersionEnterprise LKEVersionTier = "enterprise"
98+
)
99+
84100
// LKEClusterRegenerateOptions fields are those accepted by RegenerateLKECluster
85101
type LKEClusterRegenerateOptions struct {
86102
KubeConfig bool `json:"kubeconfig"`
@@ -185,6 +201,18 @@ func (c *Client) GetLKEVersion(ctx context.Context, version string) (*LKEVersion
185201
return response, nil
186202
}
187203

204+
// ListLKETierVersions lists all Kubernetes versions available given tier through LKE.
205+
// NOTE: This endpoint may not currently be available to all users and can only be used with v4beta.
206+
func (c *Client) ListLKETierVersions(ctx context.Context, tier string, opts *ListOptions) ([]LKETierVersion, error) {
207+
return getPaginatedResults[LKETierVersion](ctx, c, formatAPIPath("lke/versions/%s", tier), opts)
208+
}
209+
210+
// GetLKETierVersion gets the details of a specific LKE tier version.
211+
// NOTE: This endpoint may not currently be available to all users and can only be used with v4beta.
212+
func (c *Client) GetLKETierVersion(ctx context.Context, tier string, versionID string) (*LKETierVersion, error) {
213+
return doGETRequest[LKETierVersion](ctx, c, formatAPIPath("lke/versions/%s/%s", tier, versionID))
214+
}
215+
188216
// ListLKEClusterAPIEndpoints gets the API Endpoint for the LKE Cluster specified
189217
func (c *Client) ListLKEClusterAPIEndpoints(ctx context.Context, clusterID int, opts *ListOptions) ([]LKEClusterAPIEndpoint, error) {
190218
return getPaginatedResults[LKEClusterAPIEndpoint](ctx, c, formatAPIPath("lke/clusters/%d/api-endpoints", clusterID), opts)
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/lke/versions/standard?page=1
15+
method: GET
16+
response:
17+
body: '{"data": [{"id": "1.31", "tier": "standard"}, {"id": "1.30", "tier": "standard"}],
18+
"page": 1, "pages": 1, "results": 2}'
19+
headers:
20+
Access-Control-Allow-Credentials:
21+
- "true"
22+
Access-Control-Allow-Headers:
23+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
24+
Access-Control-Allow-Methods:
25+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
26+
Access-Control-Allow-Origin:
27+
- '*'
28+
Access-Control-Expose-Headers:
29+
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
30+
Akamai-Internal-Account:
31+
- '*'
32+
Cache-Control:
33+
- max-age=0, no-cache, no-store
34+
Connection:
35+
- keep-alive
36+
Content-Length:
37+
- "119"
38+
Content-Security-Policy:
39+
- default-src 'none'
40+
Content-Type:
41+
- application/json
42+
Expires:
43+
- Mon, 10 Feb 2025 17:36:11 GMT
44+
Pragma:
45+
- no-cache
46+
Strict-Transport-Security:
47+
- max-age=31536000
48+
Vary:
49+
- Authorization, X-Filter
50+
- Authorization, X-Filter
51+
X-Accepted-Oauth-Scopes:
52+
- lke:read_only
53+
X-Content-Type-Options:
54+
- nosniff
55+
X-Frame-Options:
56+
- DENY
57+
- DENY
58+
X-Oauth-Scopes:
59+
- account:read_write databases:read_write domains:read_write events:read_write
60+
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
61+
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
62+
volumes:read_write vpc:read_write
63+
X-Xss-Protection:
64+
- 1; mode=block
65+
status: 200 OK
66+
code: 200
67+
duration: ""
68+
- request:
69+
body: ""
70+
form: {}
71+
headers:
72+
Accept:
73+
- application/json
74+
Content-Type:
75+
- application/json
76+
User-Agent:
77+
- linodego/dev https://github.com/linode/linodego
78+
url: https://api.linode.com/v4beta/lke/versions/standard/1.31
79+
method: GET
80+
response:
81+
body: '{"id": "1.31", "tier": "standard"}'
82+
headers:
83+
Access-Control-Allow-Credentials:
84+
- "true"
85+
Access-Control-Allow-Headers:
86+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
87+
Access-Control-Allow-Methods:
88+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
89+
Access-Control-Allow-Origin:
90+
- '*'
91+
Access-Control-Expose-Headers:
92+
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
93+
Akamai-Internal-Account:
94+
- '*'
95+
Cache-Control:
96+
- max-age=0, no-cache, no-store
97+
Connection:
98+
- keep-alive
99+
Content-Length:
100+
- "34"
101+
Content-Security-Policy:
102+
- default-src 'none'
103+
Content-Type:
104+
- application/json
105+
Expires:
106+
- Mon, 10 Feb 2025 17:36:12 GMT
107+
Pragma:
108+
- no-cache
109+
Strict-Transport-Security:
110+
- max-age=31536000
111+
Vary:
112+
- Authorization, X-Filter
113+
- Authorization, X-Filter
114+
X-Accepted-Oauth-Scopes:
115+
- lke:read_only
116+
X-Content-Type-Options:
117+
- nosniff
118+
X-Frame-Options:
119+
- DENY
120+
- DENY
121+
X-Oauth-Scopes:
122+
- account:read_write databases:read_write domains:read_write events:read_write
123+
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
124+
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
125+
volumes:read_write vpc:read_write
126+
X-Ratelimit-Limit:
127+
- "1600"
128+
X-Xss-Protection:
129+
- 1; mode=block
130+
status: 200 OK
131+
code: 200
132+
duration: ""

test/integration/lke_clusters_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,33 @@ func TestLKECluster_APLEnabled_smoke(t *testing.T) {
366366
t.Errorf("Expected an APL health check URL %v, but got a different one %v", expectedHealthCheckURL, healthCheckURL)
367367
}
368368
}
369+
370+
func TestLKETierVersion_ListAndGet(t *testing.T) {
371+
client, teardown := createTestClient(t, "fixtures/TestLKETierVersion_ListAndGet")
372+
defer teardown()
373+
374+
tier := "standard"
375+
versions, err := client.ListLKETierVersions(context.Background(), tier, nil)
376+
if err != nil {
377+
t.Errorf("Error listing versions, expected struct, got %v and error %v", versions, err)
378+
}
379+
380+
if len(versions) == 0 {
381+
t.Errorf("Expected a list of versions, but got none %v", versions)
382+
}
383+
384+
for _, version := range versions {
385+
if string(version.Tier) != tier {
386+
t.Errorf("Expected version tier %v, but got %v", tier, version.Tier)
387+
}
388+
}
389+
390+
v, err := client.GetLKETierVersion(context.Background(), tier, versions[0].ID)
391+
if err != nil {
392+
t.Errorf("Error getting version, expected struct, got %v and error %v", v, err)
393+
}
394+
395+
if v.ID != versions[0].ID {
396+
t.Errorf("Expected a specific version %v, but got a different one %v", versions[0].ID, v.ID)
397+
}
398+
}

0 commit comments

Comments
 (0)