fix: pgsql user waiter
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / CI (pull_request) Failing after 19m55s
CI Workflow / Code coverage report (pull_request) Has been skipped
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 31m10s

This commit is contained in:
Marcel S. Henselin 2026-02-13 09:14:27 +01:00
parent f2c9af8fc5
commit 440e8bf900
5 changed files with 116 additions and 78 deletions

View file

@ -47,6 +47,14 @@ type APIClientUserInterface interface {
*postgresflex.GetUserResponse,
error,
)
GetDatabaseRequestExecute(
ctx context.Context,
projectId string,
region string,
instanceId string,
databaseId int32,
) (*postgresflex.GetDatabaseResponse, error)
}
// CreateInstanceWaitHandler will wait for instance creation
@ -236,3 +244,31 @@ func GetUserByIdWaitHandler(
)
return handler
}
// GetDatabaseByIdWaitHandler will wait for instance creation
func GetDatabaseByIdWaitHandler(
ctx context.Context,
a APIClientUserInterface,
projectId, instanceId, region string,
databaseId int64,
) *wait.AsyncActionHandler[postgresflex.GetDatabaseResponse] {
handler := wait.New(
func() (waitFinished bool, response *postgresflex.GetDatabaseResponse, err error) {
dbId32 := int32(databaseId)
s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, dbId32)
if err != nil {
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
if !ok {
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
}
if oapiErr.StatusCode != http.StatusNotFound {
return false, nil, err
}
return false, nil, nil
}
return true, s, nil
},
)
return handler
}