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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@
- **Dependencies:** Bump STACKIT SDK core module to `v0.26.0`
- [v0.8.0](services/scf/CHANGELOG.md#v080)
- **Feature:** Added `_UNKNOWN_DEFAULT_OPEN_API` fallback value to all enums to handle unknown API values gracefully.
- [v0.9.0](services/scf/CHANGELOG.md#v090)
- **Improvement:** Use new WaiterHelper for scf waiters
- `secretsmanager`:
- [v0.16.3](services/secretsmanager/CHANGELOG.md#v0163)
- **Dependencies:** Bump STACKIT SDK core module from `v0.24.0` to `v0.24.1`
Expand Down
3 changes: 3 additions & 0 deletions services/scf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.9.0
- **Improvement:** Use new WaiterHelper for scf waiters

## v0.8.0
- **Feature:** Added `_UNKNOWN_DEFAULT_OPEN_API` fallback value to all enums to handle unknown API values gracefully.

Expand Down
2 changes: 1 addition & 1 deletion services/scf/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.8.0
v0.9.0
32 changes: 13 additions & 19 deletions services/scf/v1api/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package wait
import (
"context"
"errors"
"fmt"
"net/http"
"time"

"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
"github.com/stackitcloud/stackit-sdk-go/core/wait"
scf "github.com/stackitcloud/stackit-sdk-go/services/scf/v1api"
)
Expand All @@ -16,24 +14,20 @@ const statusDeletingFailed = "deleting_failed"

// DeleteOrganizationWaitHandler will wait for Organization deletion
func DeleteOrganizationWaitHandler(ctx context.Context, a scf.DefaultAPI, projectId, region, orgId string) *wait.AsyncActionHandler[scf.Organization] {
handler := wait.New(func() (waitFinished bool, response *scf.Organization, err error) {
s, err := a.GetOrganization(ctx, projectId, region, orgId).Execute()
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
if ok && oapiErr.StatusCode == http.StatusNotFound {
return true, s, nil
waitConfig := wait.WaiterHelper[scf.Organization, string]{
FetchInstance: a.GetOrganization(ctx, projectId, region, orgId).Execute,
GetState: func(s *scf.Organization) (string, error) {
if s == nil {
return "", errors.New("organization is nil")
}
return false, s, err
}
if s == nil {
return false, nil, errors.New("organization is nil")
}
if s.Status == statusDeletingFailed {
return true, nil, fmt.Errorf("delete failed for Organization with id %s", orgId)
}
return false, s, nil
})
return s.Status, nil
},
ActiveState: []string{},
ErrorState: []string{statusDeletingFailed},
DeleteHttpErrorStatusCodes: []int{http.StatusNotFound},
}

handler := wait.New(waitConfig.Wait())
handler.SetTimeout(20 * time.Minute)
return handler
}
2 changes: 1 addition & 1 deletion services/scf/v1api/wait/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestDeleteOrganizationWaitHandler(t *testing.T) {
{
desc: "Instance is in error state",
wantErr: true,
returnInstance: true,
returnInstance: false,
getOrgResponse: &scf.Organization{
Status: statusDeletingFailed,
},
Expand Down
Loading