fix: linting cleanup
This commit is contained in:
parent
6b513231b3
commit
468841db57
5 changed files with 14 additions and 24 deletions
|
|
@ -170,14 +170,15 @@ func DeleteInstanceWaitHandler(
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
}
|
||||||
// TODO - maybe we want to validate status if no 404 error (only unknown or terminating should be valid)
|
// TODO - maybe we want to validate status if no 404 error (only unknown or terminating should be valid)
|
||||||
//switch *s.Status {
|
// switch *s.Status {
|
||||||
//default:
|
// default:
|
||||||
// return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
|
// return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
|
||||||
//case InstanceStateSuccess:
|
// case InstanceStateSuccess:
|
||||||
// return false, nil, nil
|
// return false, nil, nil
|
||||||
//case InstanceStateTerminating:
|
// case InstanceStateTerminating:
|
||||||
// return false, nil, nil
|
// return false, nil, nil
|
||||||
//}
|
// }
|
||||||
|
|
||||||
// TODO - add tflog for ignored cases
|
// 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
|
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 {
|
if !ok {
|
||||||
|
|
|
||||||
|
|
@ -226,12 +226,6 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
||||||
|
|
||||||
ctx = core.LogResponse(ctx)
|
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{}
|
var flavor = &flavorModel{}
|
||||||
if instanceResp != nil && instanceResp.FlavorId != nil {
|
if instanceResp != nil && instanceResp.FlavorId != nil {
|
||||||
flavor.Id = types.StringValue(*instanceResp.FlavorId)
|
flavor.Id = types.StringValue(*instanceResp.FlavorId)
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ func loadFlavorId(ctx context.Context, client postgresflexClient, model *Model,
|
||||||
}
|
}
|
||||||
if foundFlavorCount > 1 {
|
if foundFlavorCount > 1 {
|
||||||
return fmt.Errorf(
|
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),
|
len(flavorList),
|
||||||
foundFlavorCount,
|
foundFlavorCount,
|
||||||
strings.Join(foundFlavors, "\n "),
|
strings.Join(foundFlavors, "\n "),
|
||||||
|
|
@ -409,9 +409,7 @@ func getAllFlavors(ctx context.Context, client postgresflexClient, projectId, re
|
||||||
}
|
}
|
||||||
pagination := res.GetPagination()
|
pagination := res.GetPagination()
|
||||||
flavors := res.GetFlavors()
|
flavors := res.GetFlavors()
|
||||||
for _, flavor := range flavors {
|
flavorList = append(flavorList, flavors...)
|
||||||
flavorList = append(flavorList, flavor)
|
|
||||||
}
|
|
||||||
|
|
||||||
if *pagination.TotalRows < int64(len(flavorList)) {
|
if *pagination.TotalRows < int64(len(flavorList)) {
|
||||||
return nil, fmt.Errorf("total rows is smaller than current accumulated list - that should not happen")
|
return nil, fmt.Errorf("total rows is smaller than current accumulated list - that should not happen")
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
if c.returnError {
|
||||||
return nil, fmt.Errorf("get flavors failed")
|
return nil, fmt.Errorf("get flavors failed")
|
||||||
}
|
}
|
||||||
|
|
@ -457,16 +462,13 @@ func (c postgresFlexClientMocked) GetFlavorsRequestExecute(_ context.Context, _,
|
||||||
var resFlavors []postgresflex.ListFlavors
|
var resFlavors []postgresflex.ListFlavors
|
||||||
|
|
||||||
myList := responseList[c.firstItem : c.lastItem+1]
|
myList := responseList[c.firstItem : c.lastItem+1]
|
||||||
// fmt.Printf("list length: %d\n", len(myList))
|
|
||||||
|
|
||||||
firstItem := *page**size - *size
|
firstItem := *page**size - *size
|
||||||
// fmt.Printf("firstItem: %d\n", firstItem)
|
|
||||||
if firstItem > int64(len(myList)) {
|
if firstItem > int64(len(myList)) {
|
||||||
firstItem = int64(len(myList))
|
firstItem = int64(len(myList))
|
||||||
}
|
}
|
||||||
|
|
||||||
lastItem := firstItem + *size
|
lastItem := firstItem + *size
|
||||||
// fmt.Printf("lastItem: %d\n", lastItem)
|
|
||||||
if lastItem > int64(len(myList)) {
|
if lastItem > int64(len(myList)) {
|
||||||
lastItem = int64(len(myList))
|
lastItem = int64(len(myList))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -616,11 +616,6 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
||||||
|
|
||||||
ctx = core.LogResponse(ctx)
|
ctx = core.LogResponse(ctx)
|
||||||
|
|
||||||
//if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == wait.InstanceStateDeleted {
|
|
||||||
// resp.State.RemoveResource(ctx)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Map response body to schema
|
// Map response body to schema
|
||||||
err = mapFields(ctx, instanceResp, &model, flavor, storage, encryption, network, region)
|
err = mapFields(ctx, instanceResp, &model, flavor, storage, encryption, network, region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue