Skip to content

Commit f2d143a

Browse files
committed
Adjust waiters, example and changelog
Signed-off-by: Alexander Dahmen <[email protected]>
1 parent 3000f02 commit f2d143a

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## Release (2025-XX-XX)
2+
3+
- `ske`: [v1.0.0](services/ske/CHANGELOG.md#v100)
4+
- **Breaking Change:** The region is no longer specified within the client configuration. Instead, the region must be passed as a parameter to any region-specific request.
25
- `opensearch`: [v0.24.0](services/opensearch/CHANGELOG.md#v0240)
36
- **Breaking change:** `InstanceParametersTlsProtocols` is now a string array instead of a single string
47
- Add `required:"true"` tags to model structs

examples/ske/ske.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/stackitcloud/stackit-sdk-go/core/config"
98
"github.com/stackitcloud/stackit-sdk-go/core/utils"
109
"github.com/stackitcloud/stackit-sdk-go/services/ske"
1110
"github.com/stackitcloud/stackit-sdk-go/services/ske/wait"
@@ -15,10 +14,11 @@ func main() {
1514
// Specify the project ID
1615
projectId := "PROJECT_ID"
1716

17+
// Specify the region
18+
region := "REGION"
19+
1820
// Create a new API client, that uses default authentication and configuration
19-
skeClient, err := ske.NewAPIClient(
20-
config.WithRegion("eu01"),
21-
)
21+
skeClient, err := ske.NewAPIClient()
2222
if err != nil {
2323
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
2424
os.Exit(1)
@@ -33,7 +33,7 @@ func main() {
3333
// }
3434

3535
// Get the ske clusters for your project
36-
getClustersResp, err := skeClient.ListClusters(context.Background(), projectId).Execute()
36+
getClustersResp, err := skeClient.ListClusters(context.Background(), projectId, region).Execute()
3737
if err != nil {
3838
fmt.Fprintf(os.Stderr, "Error when calling `GetClusters`: %v\n", err)
3939
} else {
@@ -42,7 +42,7 @@ func main() {
4242

4343
var availableVersion string
4444
// Get the ske provider options
45-
getOptionsResp, err := skeClient.ListProviderOptions(context.Background()).Execute()
45+
getOptionsResp, err := skeClient.ListProviderOptions(context.Background(), region).Execute()
4646
if err != nil {
4747
fmt.Fprintf(os.Stderr, "Error when calling `GetOptions`: %v\n", err)
4848
} else {
@@ -77,47 +77,47 @@ func main() {
7777
},
7878
}
7979
clusterName := "cl-name"
80-
createClusterResp, err := skeClient.CreateOrUpdateCluster(context.Background(), projectId, clusterName).CreateOrUpdateClusterPayload(createInstancePayload).Execute()
80+
createClusterResp, err := skeClient.CreateOrUpdateCluster(context.Background(), projectId, region, clusterName).CreateOrUpdateClusterPayload(createInstancePayload).Execute()
8181
if err != nil {
8282
fmt.Fprintf(os.Stderr, "Error when calling `CreateCluster`: %v\n", err)
8383
} else {
8484
fmt.Printf("Triggered creation of cluster with name \"%s\".\n", *createClusterResp.Name)
8585
}
8686

8787
// Wait for cluster creation to complete
88-
_, err = wait.CreateOrUpdateClusterWaitHandler(context.Background(), skeClient, projectId, clusterName).WaitWithContext(context.Background())
88+
_, err = wait.CreateOrUpdateClusterWaitHandler(context.Background(), skeClient, projectId, region, clusterName).WaitWithContext(context.Background())
8989
if err != nil {
9090
fmt.Fprintf(os.Stderr, "Error when calling `CreateOrUpdateCluster`: %v\n", err)
9191
} else {
9292
fmt.Printf("Cluster created.\n")
9393
}
9494

9595
// Start cluster credential rotation
96-
_, err = skeClient.StartCredentialsRotationExecute(context.Background(), projectId, clusterName)
96+
_, err = skeClient.StartCredentialsRotationExecute(context.Background(), projectId, region, clusterName)
9797
if err != nil {
9898
fmt.Fprintf(os.Stderr, "Error when calling `StartCredentialsRotation`: %v\n", err)
9999
} else {
100100
fmt.Printf("Triggered start of cluster credentials rotation.\n")
101101
}
102102

103103
// Wait for cluster credential rotation to be prepared
104-
_, err = wait.StartCredentialsRotationWaitHandler(context.Background(), skeClient, projectId, clusterName).WaitWithContext(context.Background())
104+
_, err = wait.StartCredentialsRotationWaitHandler(context.Background(), skeClient, projectId, region, clusterName).WaitWithContext(context.Background())
105105
if err != nil {
106106
fmt.Fprintf(os.Stderr, "Error when calling `StartRotateCredentials`: %v\n", err)
107107
} else {
108108
fmt.Printf("Cluster credentials ready to rotate.\n")
109109
}
110110

111111
// Complete cluster credential rotation
112-
_, err = skeClient.CompleteCredentialsRotationExecute(context.Background(), projectId, clusterName)
112+
_, err = skeClient.CompleteCredentialsRotationExecute(context.Background(), projectId, region, clusterName)
113113
if err != nil {
114114
fmt.Fprintf(os.Stderr, "Error when calling `CompleteCredentialsRotation`: %v\n", err)
115115
} else {
116116
fmt.Printf("Triggered completion of cluster credentials rotation.\n")
117117
}
118118

119119
// Wait for cluster credential rotation to be completed
120-
_, err = wait.CompleteCredentialsRotationWaitHandler(context.Background(), skeClient, projectId, clusterName).WaitWithContext(context.Background())
120+
_, err = wait.CompleteCredentialsRotationWaitHandler(context.Background(), skeClient, projectId, region, clusterName).WaitWithContext(context.Background())
121121
if err != nil {
122122
fmt.Fprintf(os.Stderr, "Error when calling `CompleteRotateCredentials`: %v\n", err)
123123
} else {

services/ske/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v1.0.0
2+
- **Breaking Change:** The region is no longer specified within the client configuration. Instead, the region must be passed as a parameter to any region-specific request.
3+
14
## v0.27.0
25
- **Feature:** Add new `ClusterErrorCode` types: `CLUSTERERRORCODE_INFRA_SNA_NETWORK_NOT_FOUND`, `CLUSTERERRORCODE_FETCHING_ERRORS_NOT_POSSIBLE`
36

services/ske/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.27.0
1+
v1.0.0

services/ske/wait/wait.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ const (
3636
)
3737

3838
type APIClientClusterInterface interface {
39-
GetClusterExecute(ctx context.Context, projectId, name string) (*ske.Cluster, error)
40-
ListClustersExecute(ctx context.Context, projectId string) (*ske.ListClustersResponse, error)
39+
GetClusterExecute(ctx context.Context, projectId, region, name string) (*ske.Cluster, error)
40+
ListClustersExecute(ctx context.Context, projectId, region string) (*ske.ListClustersResponse, error)
4141
}
4242

4343
// CreateOrUpdateClusterWaitHandler will wait for cluster creation or update
44-
func CreateOrUpdateClusterWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, name string) *wait.AsyncActionHandler[ske.Cluster] {
44+
func CreateOrUpdateClusterWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, region, name string) *wait.AsyncActionHandler[ske.Cluster] {
4545
handler := wait.New(func() (waitFinished bool, response *ske.Cluster, err error) {
46-
s, err := a.GetClusterExecute(ctx, projectId, name)
46+
s, err := a.GetClusterExecute(ctx, projectId, region, name)
4747
if err != nil {
4848
return false, nil, err
4949
}
@@ -71,9 +71,9 @@ func CreateOrUpdateClusterWaitHandler(ctx context.Context, a APIClientClusterInt
7171
}
7272

7373
// DeleteClusterWaitHandler will wait for cluster deletion
74-
func DeleteClusterWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, name string) *wait.AsyncActionHandler[ske.ListClustersResponse] {
74+
func DeleteClusterWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, region, name string) *wait.AsyncActionHandler[ske.ListClustersResponse] {
7575
handler := wait.New(func() (waitFinished bool, response *ske.ListClustersResponse, err error) {
76-
s, err := a.ListClustersExecute(ctx, projectId)
76+
s, err := a.ListClustersExecute(ctx, projectId, region)
7777
if err != nil {
7878
return false, nil, err
7979
}
@@ -91,9 +91,9 @@ func DeleteClusterWaitHandler(ctx context.Context, a APIClientClusterInterface,
9191
}
9292

9393
// RotateCredentialsWaitHandler will wait for credentials rotation
94-
func RotateCredentialsWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
94+
func RotateCredentialsWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, region, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
9595
handler := wait.New(func() (waitFinished bool, response *ske.Cluster, err error) {
96-
s, err := a.GetClusterExecute(ctx, projectId, clusterName)
96+
s, err := a.GetClusterExecute(ctx, projectId, region, clusterName)
9797
if err != nil {
9898
return false, nil, err
9999
}
@@ -119,9 +119,9 @@ func RotateCredentialsWaitHandler(ctx context.Context, a APIClientClusterInterfa
119119
}
120120

121121
// StartCredentialsRotationWaitHandler will wait for credentials rotation
122-
func StartCredentialsRotationWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
122+
func StartCredentialsRotationWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, region, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
123123
handler := wait.New(func() (waitFinished bool, response *ske.Cluster, err error) {
124-
s, err := a.GetClusterExecute(ctx, projectId, clusterName)
124+
s, err := a.GetClusterExecute(ctx, projectId, region, clusterName)
125125
if err != nil {
126126
return false, nil, err
127127
}
@@ -143,9 +143,9 @@ func StartCredentialsRotationWaitHandler(ctx context.Context, a APIClientCluster
143143
}
144144

145145
// CompleteCredentialsRotationWaitHandler will wait for credentials rotation
146-
func CompleteCredentialsRotationWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
146+
func CompleteCredentialsRotationWaitHandler(ctx context.Context, a APIClientClusterInterface, projectId, region, clusterName string) *wait.AsyncActionHandler[ske.Cluster] {
147147
handler := wait.New(func() (waitFinished bool, response *ske.Cluster, err error) {
148-
s, err := a.GetClusterExecute(ctx, projectId, clusterName)
148+
s, err := a.GetClusterExecute(ctx, projectId, region, clusterName)
149149
if err != nil {
150150
return false, nil, err
151151
}

services/ske/wait/wait_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ type apiClientClusterMocked struct {
2020
invalidArgusInstance bool
2121
}
2222

23-
func (a *apiClientClusterMocked) GetClusterExecute(_ context.Context, _, _ string) (*ske.Cluster, error) {
23+
const testRegion = "eu01"
24+
25+
func (a *apiClientClusterMocked) GetClusterExecute(_ context.Context, _, _, _ string) (*ske.Cluster, error) {
2426
if a.getFails {
2527
return nil, &oapierror.GenericOpenAPIError{
2628
StatusCode: http.StatusInternalServerError,
@@ -48,7 +50,7 @@ func (a *apiClientClusterMocked) GetClusterExecute(_ context.Context, _, _ strin
4850
}, nil
4951
}
5052

51-
func (a *apiClientClusterMocked) ListClustersExecute(_ context.Context, _ string) (*ske.ListClustersResponse, error) {
53+
func (a *apiClientClusterMocked) ListClustersExecute(_ context.Context, _, _ string) (*ske.ListClustersResponse, error) {
5254
if a.getFails {
5355
return nil, &oapierror.GenericOpenAPIError{
5456
StatusCode: http.StatusInternalServerError,
@@ -147,7 +149,7 @@ func TestCreateOrUpdateClusterWaitHandler(t *testing.T) {
147149
}
148150
}
149151

150-
handler := CreateOrUpdateClusterWaitHandler(context.Background(), apiClient, "", name)
152+
handler := CreateOrUpdateClusterWaitHandler(context.Background(), apiClient, "", testRegion, name)
151153

152154
gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
153155

@@ -223,7 +225,7 @@ func TestRotateCredentialsWaitHandler(t *testing.T) {
223225
}
224226
}
225227

226-
handler := RotateCredentialsWaitHandler(context.Background(), apiClient, "", name)
228+
handler := RotateCredentialsWaitHandler(context.Background(), apiClient, "", testRegion, name)
227229

228230
gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
229231

0 commit comments

Comments
 (0)