fix: linting cleanup

This commit is contained in:
Marcel_Henselin 2025-12-30 16:43:42 +01:00
parent 6b513231b3
commit 468841db57
5 changed files with 14 additions and 24 deletions

View file

@ -170,14 +170,15 @@ func DeleteInstanceWaitHandler(
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:
// switch *s.Status {
// default:
// return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
//case InstanceStateSuccess:
// case InstanceStateSuccess:
// return false, nil, nil
//case InstanceStateTerminating:
// 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 {

View file

@ -226,12 +226,6 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
ctx = core.LogResponse(ctx)
//if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == wait.InstanceStateDeleted {
// resp.State.RemoveResource(ctx)
// core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", "Instance was deleted successfully")
// return
//}
var flavor = &flavorModel{}
if instanceResp != nil && instanceResp.FlavorId != nil {
flavor.Id = types.StringValue(*instanceResp.FlavorId)

View file

@ -376,7 +376,7 @@ func loadFlavorId(ctx context.Context, client postgresflexClient, model *Model,
}
if foundFlavorCount > 1 {
return fmt.Errorf(
"number of flavors returned: %d\nmultiple flavors found: %d flavors\n %s\n",
"number of flavors returned: %d\nmultiple flavors found: %d flavors\n %s",
len(flavorList),
foundFlavorCount,
strings.Join(foundFlavors, "\n "),
@ -409,9 +409,7 @@ func getAllFlavors(ctx context.Context, client postgresflexClient, projectId, re
}
pagination := res.GetPagination()
flavors := res.GetFlavors()
for _, flavor := range flavors {
flavorList = append(flavorList, flavor)
}
flavorList = append(flavorList, flavors...)
if *pagination.TotalRows < int64(len(flavorList)) {
return nil, fmt.Errorf("total rows is smaller than current accumulated list - that should not happen")

View file

@ -448,7 +448,12 @@ func testFlavorToResponseFlavor(f testFlavor) postgresflex.ListFlavors {
}
}
func (c postgresFlexClientMocked) GetFlavorsRequestExecute(_ context.Context, _, _ string, page *int64, size *int64, _ *postgresflex.FlavorSort) (*postgresflex.GetFlavorsResponse, error) {
func (c postgresFlexClientMocked) GetFlavorsRequestExecute(
_ context.Context,
_, _ string,
page, size *int64,
_ *postgresflex.FlavorSort,
) (*postgresflex.GetFlavorsResponse, error) {
if c.returnError {
return nil, fmt.Errorf("get flavors failed")
}
@ -457,16 +462,13 @@ func (c postgresFlexClientMocked) GetFlavorsRequestExecute(_ context.Context, _,
var resFlavors []postgresflex.ListFlavors
myList := responseList[c.firstItem : c.lastItem+1]
// fmt.Printf("list length: %d\n", len(myList))
firstItem := *page**size - *size
// fmt.Printf("firstItem: %d\n", firstItem)
if firstItem > int64(len(myList)) {
firstItem = int64(len(myList))
}
lastItem := firstItem + *size
// fmt.Printf("lastItem: %d\n", lastItem)
if lastItem > int64(len(myList)) {
lastItem = int64(len(myList))
}

View file

@ -616,11 +616,6 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
ctx = core.LogResponse(ctx)
//if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == wait.InstanceStateDeleted {
// resp.State.RemoveResource(ctx)
// return
//}
// Map response body to schema
err = mapFields(ctx, instanceResp, &model, flavor, storage, encryption, network, region)
if err != nil {