Skip to content
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
2 changes: 1 addition & 1 deletion CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Your contribution is welcome! Thank you for your interest in contributing to the

## Developer Guide
### Repository structure
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).
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).

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.

Expand Down
20 changes: 0 additions & 20 deletions examples/waiter/go.mod

This file was deleted.

36 changes: 0 additions & 36 deletions examples/waiter/go.sum

This file was deleted.

56 changes: 0 additions & 56 deletions examples/waiter/waiter.go

This file was deleted.

1 change: 0 additions & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use (
./examples/redis
./examples/secretsmanager
./examples/ske
./examples/waiter
./services/argus
./services/dns
./services/loadbalancer
Expand Down
7 changes: 4 additions & 3 deletions services/argus/wait.go → services/argus/wait/wait.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package argus
package wait

import (
"context"
"fmt"

"github.com/stackitcloud/stackit-sdk-go/core/wait"
"github.com/stackitcloud/stackit-sdk-go/services/argus"
)

const (
Expand All @@ -18,8 +19,8 @@ const (

// APIClientInterface Interfaces needed for tests
type APIClientInterface interface {
GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*InstanceResponse, error)
GetScrapeConfigsExecute(ctx context.Context, instanceId, projectId string) (*ScrapeConfigsResponse, error)
GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*argus.InstanceResponse, error)
GetScrapeConfigsExecute(ctx context.Context, instanceId, projectId string) (*argus.ScrapeConfigsResponse, error)
}

// will wait for creation
Expand Down
59 changes: 30 additions & 29 deletions services/argus/wait_test.go → services/argus/wait/wait_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package argus
package wait

import (
"context"
Expand All @@ -9,35 +9,36 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
oapiError "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/argus"
)

type apiClientMocked struct {
getFails bool
resourceState *string
jobs []Job
jobs []argus.Job
}

func (a *apiClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*InstanceResponse, error) {
func (a *apiClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*argus.InstanceResponse, error) {
if a.getFails {
return nil, &oapiError.GenericOpenAPIError{
StatusCode: 500,
}
}

return &InstanceResponse{
return &argus.InstanceResponse{
Id: utils.Ptr("iid"),
Status: a.resourceState,
}, nil
}

func (a *apiClientMocked) GetScrapeConfigsExecute(_ context.Context, _, _ string) (*ScrapeConfigsResponse, error) {
func (a *apiClientMocked) GetScrapeConfigsExecute(_ context.Context, _, _ string) (*argus.ScrapeConfigsResponse, error) {
if a.getFails {
return nil, &oapiError.GenericOpenAPIError{
StatusCode: 500,
}
}

return &ScrapeConfigsResponse{
return &argus.ScrapeConfigsResponse{
Data: &a.jobs,
}, nil
}
Expand Down Expand Up @@ -87,9 +88,9 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
resourceState: tt.resourceState,
}

var wantRes *InstanceResponse
var wantRes *argus.InstanceResponse
if !tt.getFails {
wantRes = &InstanceResponse{
wantRes = &argus.InstanceResponse{
Id: utils.Ptr("iid"),
Status: tt.resourceState,
}
Expand All @@ -107,7 +108,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
if wantRes == nil && gotRes != nil {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
Expand Down Expand Up @@ -153,9 +154,9 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
resourceState: tt.resourceState,
}

var wantRes *InstanceResponse
var wantRes *argus.InstanceResponse
if !tt.getFails {
wantRes = &InstanceResponse{
wantRes = &argus.InstanceResponse{
Status: tt.resourceState,
Id: utils.Ptr("iid"),
}
Expand All @@ -173,7 +174,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
if wantRes == nil && gotRes != nil {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
Expand Down Expand Up @@ -219,9 +220,9 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
resourceState: tt.resourceState,
}

var wantRes *InstanceResponse
var wantRes *argus.InstanceResponse
if !tt.getFails {
wantRes = &InstanceResponse{
wantRes = &argus.InstanceResponse{
Status: tt.resourceState,
Id: utils.Ptr("iid"),
}
Expand All @@ -239,7 +240,7 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
if wantRes == nil && gotRes != nil {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
Expand All @@ -250,25 +251,25 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
tests := []struct {
desc string
getFails bool
jobs []Job
jobs []argus.Job
wantErr bool
}{
{
desc: "create_succeeded",
getFails: false,
jobs: []Job{{JobName: utils.Ptr("job")}, {JobName: utils.Ptr("other-job")}},
jobs: []argus.Job{{JobName: utils.Ptr("job")}, {JobName: utils.Ptr("other-job")}},
wantErr: false,
},
{
desc: "create_failed and timeout",
getFails: false,
jobs: []Job{{JobName: utils.Ptr("other-job")}},
jobs: []argus.Job{{JobName: utils.Ptr("other-job")}},
wantErr: true,
},
{
desc: "get_fails",
getFails: true,
jobs: []Job{},
jobs: []argus.Job{},
wantErr: true,
},
}
Expand All @@ -279,9 +280,9 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
jobs: tt.jobs,
}

var wantRes *ScrapeConfigsResponse
var wantRes *argus.ScrapeConfigsResponse
if !tt.getFails {
wantRes = &ScrapeConfigsResponse{
wantRes = &argus.ScrapeConfigsResponse{
Data: &tt.jobs,
}
} else {
Expand All @@ -298,7 +299,7 @@ func TestCreateScrapeConfigWaitHandler(t *testing.T) {
if wantRes == nil && gotRes != nil {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
Expand All @@ -309,25 +310,25 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
tests := []struct {
desc string
getFails bool
jobs []Job
jobs []argus.Job
wantErr bool
}{
{
desc: "delete_succeeded",
getFails: false,
jobs: []Job{{JobName: utils.Ptr("other-job")}},
jobs: []argus.Job{{JobName: utils.Ptr("other-job")}},
wantErr: false,
},
{
desc: "timeout",
getFails: false,
jobs: []Job{{JobName: utils.Ptr("job")}},
jobs: []argus.Job{{JobName: utils.Ptr("job")}},
wantErr: true,
},
{
desc: "get_fails",
getFails: true,
jobs: []Job{},
jobs: []argus.Job{},
wantErr: true,
},
}
Expand All @@ -338,9 +339,9 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
jobs: tt.jobs,
}

var wantRes *ScrapeConfigsResponse
var wantRes *argus.ScrapeConfigsResponse
if !tt.getFails {
wantRes = &ScrapeConfigsResponse{
wantRes = &argus.ScrapeConfigsResponse{
Data: &tt.jobs,
}
} else {
Expand All @@ -357,7 +358,7 @@ func TestDeleteScrapeConfigWaitHandler(t *testing.T) {
if wantRes == nil && gotRes != nil {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(NullableString{})) {
if wantRes != nil && !cmp.Equal(gotRes, wantRes, cmpopts.IgnoreUnexported(argus.NullableString{})) {
t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes)
}
})
Expand Down
7 changes: 4 additions & 3 deletions services/dns/wait.go → services/dns/wait/wait.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dns
package wait

import (
"context"
"fmt"

"github.com/stackitcloud/stackit-sdk-go/core/wait"
"github.com/stackitcloud/stackit-sdk-go/services/dns"
)

const (
Expand All @@ -18,8 +19,8 @@ const (

// Interfaces needed for tests
type APIClientInterface interface {
GetZoneExecute(ctx context.Context, projectId, zoneId string) (*ZoneResponse, error)
GetRecordSetExecute(ctx context.Context, projectId, zoneId, rrSetId string) (*RecordSetResponse, error)
GetZoneExecute(ctx context.Context, projectId, zoneId string) (*dns.ZoneResponse, error)
GetRecordSetExecute(ctx context.Context, projectId, zoneId, rrSetId string) (*dns.RecordSetResponse, error)
}

// CreateZoneWaitHandler will wait for creation
Expand Down
Loading