Skip to content

Commit f932e81

Browse files
hcsa73Henrique Santosvicentepinto98
authored
Services - move waiter to package (#98)
* Move waiters to wait package * Update with change of location of wait files * Fix typo Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Remove waiter example --------- Co-authored-by: Henrique Santos <henrique.santos@freiheit.com> Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com>
1 parent 7a6e388 commit f932e81

36 files changed

Lines changed: 989 additions & 1074 deletions

File tree

CONTRIBUTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Your contribution is welcome! Thank you for your interest in contributing to the
88

99
## Developer Guide
1010
### Repository structure
11-
The SDK STACKIT service modules are located under `services`, which are automatically generated from the [REST API specs](https://github.com/stackitcloud/stackit-api-specifications), except for the `wait.go` and `wait_test.go` files. Therefore, changes to these modules besides the `wait.go` and `wait_test.go` files will not be accepted. Instead, consider proposing changes to the generation process in the [Generator repository](https://github.com/stackitcloud/stackit-sdk-generator).
11+
The SDK STACKIT service modules are located under `services`. The files located in `services/[service]` are automatically generated from the [REST API specs](https://github.com/stackitcloud/stackit-api-specifications), whereas the ones located in subfolders (like `wait`) are manually maintained. Therefore, changes to files located in `services/[service]` will not be accepted. Instead, consider proposing changes to the generation process in the [Generator repository](https://github.com/stackitcloud/stackit-sdk-generator).
1212

1313
Inside `core` you can find several packages that are used by all service modules, such as `auth`, `config` and `wait`. Examples of usage of the SDK are located under the `examples` folder.
1414

examples/waiter/go.mod

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/waiter/go.sum

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/waiter/waiter.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

go.work

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use (
1818
./examples/redis
1919
./examples/secretsmanager
2020
./examples/ske
21-
./examples/waiter
2221
./services/argus
2322
./services/dns
2423
./services/loadbalancer
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package argus
1+
package wait
22

33
import (
44
"context"
55
"fmt"
66

77
"github.com/stackitcloud/stackit-sdk-go/core/wait"
8+
"github.com/stackitcloud/stackit-sdk-go/services/argus"
89
)
910

1011
const (
@@ -18,8 +19,8 @@ const (
1819

1920
// APIClientInterface Interfaces needed for tests
2021
type APIClientInterface interface {
21-
GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*InstanceResponse, error)
22-
GetScrapeConfigsExecute(ctx context.Context, instanceId, projectId string) (*ScrapeConfigsResponse, error)
22+
GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*argus.InstanceResponse, error)
23+
GetScrapeConfigsExecute(ctx context.Context, instanceId, projectId string) (*argus.ScrapeConfigsResponse, error)
2324
}
2425

2526
// will wait for creation
Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package argus
1+
package wait
22

33
import (
44
"context"
@@ -9,35 +9,36 @@ import (
99
"github.com/google/go-cmp/cmp/cmpopts"
1010
oapiError "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
1111
"github.com/stackitcloud/stackit-sdk-go/core/utils"
12+
"github.com/stackitcloud/stackit-sdk-go/services/argus"
1213
)
1314

1415
type apiClientMocked struct {
1516
getFails bool
1617
resourceState *string
17-
jobs []Job
18+
jobs []argus.Job
1819
}
1920

20-
func (a *apiClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*InstanceResponse, error) {
21+
func (a *apiClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*argus.InstanceResponse, error) {
2122
if a.getFails {
2223
return nil, &oapiError.GenericOpenAPIError{
2324
StatusCode: 500,
2425
}
2526
}
2627

27-
return &InstanceResponse{
28+
return &argus.InstanceResponse{
2829
Id: utils.Ptr("iid"),
2930
Status: a.resourceState,
3031
}, nil
3132
}
3233

33-
func (a *apiClientMocked) GetScrapeConfigsExecute(_ context.Context, _, _ string) (*ScrapeConfigsResponse, error) {
34+
func (a *apiClientMocked) GetScrapeConfigsExecute(_ context.Context, _, _ string) (*argus.ScrapeConfigsResponse, error) {
3435
if a.getFails {
3536
return nil, &oapiError.GenericOpenAPIError{
3637
StatusCode: 500,
3738
}
3839
}
3940

40-
return &ScrapeConfigsResponse{
41+
return &argus.ScrapeConfigsResponse{
4142
Data: &a.jobs,
4243
}, nil
4344
}
@@ -87,9 +88,9 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
8788
resourceState: tt.resourceState,
8889
}
8990

90-
var wantRes *InstanceResponse
91+
var wantRes *argus.InstanceResponse
9192
if !tt.getFails {
92-
wantRes = &InstanceResponse{
93+
wantRes = &argus.InstanceResponse{
9394
Id: utils.Ptr("iid"),
9495
Status: tt.resourceState,
9596
}
@@ -107,7 +108,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
107108
if wantRes == nil && gotRes != nil {
108109
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
109110
}
110-
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
111+
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
111112
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
112113
}
113114
})
@@ -153,9 +154,9 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
153154
resourceState: tt.resourceState,
154155
}
155156

156-
var wantRes *InstanceResponse
157+
var wantRes *argus.InstanceResponse
157158
if !tt.getFails {
158-
wantRes = &InstanceResponse{
159+
wantRes = &argus.InstanceResponse{
159160
Status: tt.resourceState,
160161
Id: utils.Ptr("iid"),
161162
}
@@ -173,7 +174,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
173174
if wantRes == nil && gotRes != nil {
174175
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
175176
}
176-
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
177+
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
177178
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
178179
}
179180
})
@@ -219,9 +220,9 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
219220
resourceState: tt.resourceState,
220221
}
221222

222-
var wantRes *InstanceResponse
223+
var wantRes *argus.InstanceResponse
223224
if !tt.getFails {
224-
wantRes = &InstanceResponse{
225+
wantRes = &argus.InstanceResponse{
225226
Status: tt.resourceState,
226227
Id: utils.Ptr("iid"),
227228
}
@@ -239,7 +240,7 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
239240
if wantRes == nil && gotRes != nil {
240241
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
241242
}
242-
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
243+
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
243244
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
244245
}
245246
})
@@ -250,25 +251,25 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
250251
tests := []struct {
251252
desc string
252253
getFails bool
253-
jobs []Job
254+
jobs []argus.Job
254255
wantErr bool
255256
}{
256257
{
257258
desc: "create_succeeded",
258259
getFails: false,
259-
jobs: []Job{{JobName: utils.Ptr("job")}, {JobName: utils.Ptr("other-job")}},
260+
jobs: []argus.Job{{JobName: utils.Ptr("job")}, {JobName: utils.Ptr("other-job")}},
260261
wantErr: false,
261262
},
262263
{
263264
desc: "create_failed and timeout",
264265
getFails: false,
265-
jobs: []Job{{JobName: utils.Ptr("other-job")}},
266+
jobs: []argus.Job{{JobName: utils.Ptr("other-job")}},
266267
wantErr: true,
267268
},
268269
{
269270
desc: "get_fails",
270271
getFails: true,
271-
jobs: []Job{},
272+
jobs: []argus.Job{},
272273
wantErr: true,
273274
},
274275
}
@@ -279,9 +280,9 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
279280
jobs: tt.jobs,
280281
}
281282

282-
var wantRes *ScrapeConfigsResponse
283+
var wantRes *argus.ScrapeConfigsResponse
283284
if !tt.getFails {
284-
wantRes = &ScrapeConfigsResponse{
285+
wantRes = &argus.ScrapeConfigsResponse{
285286
Data: &tt.jobs,
286287
}
287288
} else {
@@ -298,7 +299,7 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
298299
if wantRes == nil && gotRes != nil {
299300
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
300301
}
301-
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
302+
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
302303
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
303304
}
304305
})
@@ -309,25 +310,25 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
309310
tests := []struct {
310311
desc string
311312
getFails bool
312-
jobs []Job
313+
jobs []argus.Job
313314
wantErr bool
314315
}{
315316
{
316317
desc: "delete_succeeded",
317318
getFails: false,
318-
jobs: []Job{{JobName: utils.Ptr("other-job")}},
319+
jobs: []argus.Job{{JobName: utils.Ptr("other-job")}},
319320
wantErr: false,
320321
},
321322
{
322323
desc: "timeout",
323324
getFails: false,
324-
jobs: []Job{{JobName: utils.Ptr("job")}},
325+
jobs: []argus.Job{{JobName: utils.Ptr("job")}},
325326
wantErr: true,
326327
},
327328
{
328329
desc: "get_fails",
329330
getFails: true,
330-
jobs: []Job{},
331+
jobs: []argus.Job{},
331332
wantErr: true,
332333
},
333334
}
@@ -338,9 +339,9 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
338339
jobs: tt.jobs,
339340
}
340341

341-
var wantRes *ScrapeConfigsResponse
342+
var wantRes *argus.ScrapeConfigsResponse
342343
if !tt.getFails {
343-
wantRes = &ScrapeConfigsResponse{
344+
wantRes = &argus.ScrapeConfigsResponse{
344345
Data: &tt.jobs,
345346
}
346347
} else {
@@ -357,7 +358,7 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
357358
if wantRes == nil && gotRes != nil {
358359
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
359360
}
360-
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
361+
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
361362
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
362363
}
363364
})
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package dns
1+
package wait
22

33
import (
44
"context"
55
"fmt"
66

77
"github.com/stackitcloud/stackit-sdk-go/core/wait"
8+
"github.com/stackitcloud/stackit-sdk-go/services/dns"
89
)
910

1011
const (
@@ -18,8 +19,8 @@ const (
1819

1920
// Interfaces needed for tests
2021
type APIClientInterface interface {
21-
GetZoneExecute(ctx context.Context, projectId, zoneId string) (*ZoneResponse, error)
22-
GetRecordSetExecute(ctx context.Context, projectId, zoneId, rrSetId string) (*RecordSetResponse, error)
22+
GetZoneExecute(ctx context.Context, projectId, zoneId string) (*dns.ZoneResponse, error)
23+
GetRecordSetExecute(ctx context.Context, projectId, zoneId, rrSetId string) (*dns.RecordSetResponse, error)
2324
}
2425

2526
// CreateZoneWaitHandler will wait for creation

0 commit comments

Comments
 (0)