From 468841db576a093c9cc5ca9b2bd4025d04472258 Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Tue, 30 Dec 2025 16:43:42 +0100 Subject: [PATCH] fix: linting cleanup --- pkg/postgresflexalpha/wait/wait.go | 11 ++++++----- .../services/postgresflexalpha/instance/datasource.go | 6 ------ .../services/postgresflexalpha/instance/functions.go | 6 ++---- .../postgresflexalpha/instance/functions_test.go | 10 ++++++---- .../services/postgresflexalpha/instance/resource.go | 5 ----- 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/pkg/postgresflexalpha/wait/wait.go b/pkg/postgresflexalpha/wait/wait.go index e1c51dce..cbac012b 100644 --- a/pkg/postgresflexalpha/wait/wait.go +++ b/pkg/postgresflexalpha/wait/wait.go @@ -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 { diff --git a/stackit/internal/services/postgresflexalpha/instance/datasource.go b/stackit/internal/services/postgresflexalpha/instance/datasource.go index b9d5edcb..98aeb59f 100644 --- a/stackit/internal/services/postgresflexalpha/instance/datasource.go +++ b/stackit/internal/services/postgresflexalpha/instance/datasource.go @@ -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) diff --git a/stackit/internal/services/postgresflexalpha/instance/functions.go b/stackit/internal/services/postgresflexalpha/instance/functions.go index 9f7d0482..f415cc69 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions.go @@ -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") diff --git a/stackit/internal/services/postgresflexalpha/instance/functions_test.go b/stackit/internal/services/postgresflexalpha/instance/functions_test.go index d6468b87..51991c9c 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions_test.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions_test.go @@ -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)) } diff --git a/stackit/internal/services/postgresflexalpha/instance/resource.go b/stackit/internal/services/postgresflexalpha/instance/resource.go index 55fd34cf..2787656a 100644 --- a/stackit/internal/services/postgresflexalpha/instance/resource.go +++ b/stackit/internal/services/postgresflexalpha/instance/resource.go @@ -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 {