chore: adjust pagination for postgres database and flavor listing (#20)
* feat: implement pagination for database listing * fix: change database_id attribute type from string to int64 * refactor: rename getDatabase to getDatabaseById for clarity * fix: improve error handling for database not found scenario * feat: add validation for database_id and name attributes; implement separate functions for fetching databases by ID and name * feat: implement database client interface and update database fetching functions * refactor: rename matcher to filter for clarity and update pagination logic * feat: implement flavors retrieval with pagination and filtering support * refactor: rename flavor import for consistency and clarity * feat: add support for InstanceStatePending in wait handler logic * refactor: simplify GetFlavorsRequest and GetFlavorsRequestExecute by removing pagination parameters * refactor: improve readability of test cases by formatting function signatures and restructuring test runs * refactor: remove pagination parameters from GetFlavorsRequest in test case * refactor: simplify function signatures and improve readability in datasource and resource files * refactor: add descriptions for user-related attributes in datasource schema * refactor: enhance user resource schema with additional attributes and improve logging * refactor: delete unused file * refactor: standardize formatting and improve function naming for user resource management * refactor: remove skip from TestMapFields and update roles initialization in resource tests * fix: golangci lint issues * fix: golangci lint issues again * fix: golangci lint issues again
This commit is contained in:
parent
0150fea302
commit
979220be66
26 changed files with 3630 additions and 2759 deletions
|
|
@ -142,6 +142,8 @@ func PartialUpdateInstanceWaitHandler(
|
|||
return false, nil, nil
|
||||
case InstanceStateProgressing:
|
||||
return false, nil, nil
|
||||
case InstanceStatePending:
|
||||
return false, nil, nil
|
||||
case InstanceStateTerminating:
|
||||
return false, nil, nil
|
||||
case InstanceStateSuccess:
|
||||
|
|
@ -154,96 +156,3 @@ func PartialUpdateInstanceWaitHandler(
|
|||
handler.SetTimeout(45 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
||||
//// DeleteInstanceWaitHandler will wait for instance deletion
|
||||
//func DeleteInstanceWaitHandler(
|
||||
// ctx context.Context,
|
||||
// a APIClientInstanceInterface,
|
||||
// projectId, region, instanceId string,
|
||||
//) *wait.AsyncActionHandler[struct{}] {
|
||||
// handler := wait.New(
|
||||
// func() (waitFinished bool, response *struct{}, err error) {
|
||||
// s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
// if err != nil {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
|
||||
// return false, nil, nil
|
||||
// }
|
||||
// // TODO - maybe we want to validate status if no 404 error (only unknown or terminating should be valid)
|
||||
// // switch *s.Status {
|
||||
// // default:
|
||||
// // return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
|
||||
// // case InstanceStateSuccess:
|
||||
// // return false, nil, nil
|
||||
// // case InstanceStateTerminating:
|
||||
// // return false, nil, nil
|
||||
// // }
|
||||
//
|
||||
// // TODO - add tflog for ignored cases
|
||||
// oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
// if !ok {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if oapiErr.StatusCode != 404 {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// return true, nil, nil
|
||||
// },
|
||||
// )
|
||||
// handler.SetTimeout(5 * time.Minute)
|
||||
// return handler
|
||||
//}
|
||||
//
|
||||
//// TODO - remove
|
||||
//// ForceDeleteInstanceWaitHandler will wait for instance deletion
|
||||
//func ForceDeleteInstanceWaitHandler(
|
||||
// ctx context.Context,
|
||||
// a APIClientInstanceInterface,
|
||||
// projectId, region, instanceId string,
|
||||
//) *wait.AsyncActionHandler[struct{}] {
|
||||
// handler := wait.New(
|
||||
// func() (waitFinished bool, response *struct{}, err error) {
|
||||
// _, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
// if err == nil {
|
||||
// return false, nil, nil
|
||||
// }
|
||||
// oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
// if !ok {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// if oapiErr.StatusCode != 404 {
|
||||
// return false, nil, err
|
||||
// }
|
||||
// return true, nil, nil
|
||||
// },
|
||||
// )
|
||||
// handler.SetTimeout(15 * time.Minute)
|
||||
// return handler
|
||||
//}
|
||||
|
||||
// DeleteUserWaitHandler will wait for delete
|
||||
func DeleteUserWaitHandler(
|
||||
ctx context.Context,
|
||||
a APIClientUserInterface,
|
||||
projectId, region, instanceId string, userId int64,
|
||||
) *wait.AsyncActionHandler[struct{}] {
|
||||
handler := wait.New(
|
||||
func() (waitFinished bool, response *struct{}, err error) {
|
||||
_, err = a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId)
|
||||
if err == nil {
|
||||
return false, nil, nil
|
||||
}
|
||||
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
if !ok {
|
||||
return false, nil, err
|
||||
}
|
||||
if oapiErr.StatusCode != 404 {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, nil, nil
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(1 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue