Skip to content

Commit 0f7502c

Browse files
committed
fix: IaaS dependency in waiters
1 parent 3d8214f commit 0f7502c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

services/iaas/wait/wait.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
1010
"github.com/stackitcloud/stackit-sdk-go/core/wait"
1111
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
12-
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
1312
)
1413

1514
const (
@@ -46,7 +45,7 @@ type APIClientInterface interface {
4645
GetVolumeExecute(ctx context.Context, projectId string, volumeId string) (*iaas.Volume, error)
4746
GetServerExecute(ctx context.Context, projectId string, serverId string) (*iaas.Server, error)
4847
GetAttachedVolumeExecute(ctx context.Context, projectId string, serverId string, volumeId string) (*iaas.VolumeAttachment, error)
49-
GetImageExecute(ctx context.Context, projectId string, imageId string) (*iaasalpha.Image, error)
48+
GetImageExecute(ctx context.Context, projectId string, imageId string) (*iaas.Image, error)
5049
}
5150

5251
// CreateNetworkAreaWaitHandler will wait for network area creation
@@ -552,8 +551,8 @@ func RemoveVolumeFromServerWaitHandler(ctx context.Context, a APIClientInterface
552551
}
553552

554553
// UploadImageWaitHandler will wait for the status image to become AVAILABLE, which indicates the upload of the image has been completed successfully
555-
func UploadImageWaitHandler(ctx context.Context, a APIClientInterface, projectId, imageId string) *wait.AsyncActionHandler[iaasalpha.Image] {
556-
handler := wait.New(func() (waitFinished bool, response *iaasalpha.Image, err error) {
554+
func UploadImageWaitHandler(ctx context.Context, a APIClientInterface, projectId, imageId string) *wait.AsyncActionHandler[iaas.Image] {
555+
handler := wait.New(func() (waitFinished bool, response *iaas.Image, err error) {
557556
image, err := a.GetImageExecute(ctx, projectId, imageId)
558557
if err != nil {
559558
return false, image, err
@@ -574,8 +573,8 @@ func UploadImageWaitHandler(ctx context.Context, a APIClientInterface, projectId
574573
}
575574

576575
// DeleteImageWaitHandler will wait for image deletion
577-
func DeleteImageWaitHandler(ctx context.Context, a APIClientInterface, projectId, imageId string) *wait.AsyncActionHandler[iaasalpha.Image] {
578-
handler := wait.New(func() (waitFinished bool, response *iaasalpha.Image, err error) {
576+
func DeleteImageWaitHandler(ctx context.Context, a APIClientInterface, projectId, imageId string) *wait.AsyncActionHandler[iaas.Image] {
577+
handler := wait.New(func() (waitFinished bool, response *iaas.Image, err error) {
579578
image, err := a.GetImageExecute(ctx, projectId, imageId)
580579
if err == nil {
581580
if image != nil {

services/iaas/wait/wait_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
1010
"github.com/stackitcloud/stackit-sdk-go/core/utils"
1111
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
12-
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
1312
)
1413

1514
type apiClientMocked struct {
@@ -144,7 +143,7 @@ func (a *apiClientMocked) GetAttachedVolumeExecute(_ context.Context, _, _, _ st
144143
}, nil
145144
}
146145

147-
func (a *apiClientMocked) GetImageExecute(_ context.Context, _, _ string) (*iaasalpha.Image, error) {
146+
func (a *apiClientMocked) GetImageExecute(_ context.Context, _, _ string) (*iaas.Image, error) {
148147
if a.getImageFails {
149148
return nil, &oapierror.GenericOpenAPIError{
150149
StatusCode: 500,
@@ -157,7 +156,7 @@ func (a *apiClientMocked) GetImageExecute(_ context.Context, _, _ string) (*iaas
157156
}
158157
}
159158

160-
return &iaasalpha.Image{
159+
return &iaas.Image{
161160
Id: utils.Ptr("iid"),
162161
Status: &a.resourceState,
163162
}, nil
@@ -1438,9 +1437,9 @@ func TestUploadImageWaitHandler(t *testing.T) {
14381437
resourceState: tt.resourceState,
14391438
}
14401439

1441-
var wantRes *iaasalpha.Image
1440+
var wantRes *iaas.Image
14421441
if tt.wantResp {
1443-
wantRes = &iaasalpha.Image{
1442+
wantRes = &iaas.Image{
14441443
Id: utils.Ptr("iid"),
14451444
Status: utils.Ptr(tt.resourceState),
14461445
}

0 commit comments

Comments
 (0)