From a33804e4353646bd4c85202286fdf5142b3761cb Mon Sep 17 00:00:00 2001 From: Eric Miller Date: Thu, 30 Jul 2026 12:19:06 -0500 Subject: [PATCH 1/3] chore: fix prealloc findings --- .golangci.yaml | 2 +- coreweave/cks/resource_cluster_test.go | 7 ++++--- .../data_source_bucket_policy_document.go | 15 +++++++++------ coreweave/object_storage/resource_bucket_test.go | 5 +++-- .../resource_organization_access_policy.go | 8 ++++---- .../resource_organization_access_policy_test.go | 13 +++++++------ 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 4d4e5a8a..40102c75 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -23,7 +23,7 @@ linters: - revive - makezero - nakedret - # - prealloc + - prealloc - nolintlint - staticcheck - thelper diff --git a/coreweave/cks/resource_cluster_test.go b/coreweave/cks/resource_cluster_test.go index e04c5925..b0443459 100644 --- a/coreweave/cks/resource_cluster_test.go +++ b/coreweave/cks/resource_cluster_test.go @@ -299,8 +299,9 @@ func createClusterTestStep(ctx context.Context, t *testing.T, config testStepCon } // internal lb cidrs - internalLbCidrs := []knownvalue.Check{} - for _, c := range config.cluster.InternalLbCidrNames(ctx) { + internalLbCidrNames := config.cluster.InternalLbCidrNames(ctx) + internalLbCidrs := make([]knownvalue.Check, 0, len(internalLbCidrNames)) + for _, c := range internalLbCidrNames { internalLbCidrs = append(internalLbCidrs, knownvalue.StringExact(c)) } statechecks = append(statechecks, statecheck.ExpectKnownValue(config.Resources.FullResourceName, tfjsonpath.New("internal_lb_cidr_names"), knownvalue.ListExact(internalLbCidrs))) @@ -327,7 +328,7 @@ func createClusterTestStep(ctx context.Context, t *testing.T, config testStepCon t.FailNow() } - checks := []knownvalue.Check{} + checks := make([]knownvalue.Check, 0, len(algs)) for _, a := range algs { checks = append(checks, knownvalue.StringExact(a.ValueString())) } diff --git a/coreweave/object_storage/data_source_bucket_policy_document.go b/coreweave/object_storage/data_source_bucket_policy_document.go index 29185098..f6545668 100644 --- a/coreweave/object_storage/data_source_bucket_policy_document.go +++ b/coreweave/object_storage/data_source_bucket_policy_document.go @@ -375,8 +375,9 @@ func MustRenderBucketPolicyDocument(_ context.Context, name string, cfg *BucketP // action list if !s.Action.IsNull() { - var vals []cty.Value - for _, v := range s.Action.Elements() { + elements := s.Action.Elements() + vals := make([]cty.Value, 0, len(elements)) + for _, v := range elements { str := v.(types.String).ValueString() vals = append(vals, cty.StringVal(str)) } @@ -385,8 +386,9 @@ func MustRenderBucketPolicyDocument(_ context.Context, name string, cfg *BucketP // resource list if !s.Resource.IsNull() { - var vals []cty.Value - for _, v := range s.Resource.Elements() { + elements := s.Resource.Elements() + vals := make([]cty.Value, 0, len(elements)) + for _, v := range elements { str := v.(types.String).ValueString() vals = append(vals, cty.StringVal(str)) } @@ -399,8 +401,9 @@ func MustRenderBucketPolicyDocument(_ context.Context, name string, cfg *BucketP for key, val := range s.Principal.Elements() { // val is types.List list := val.(types.List) - var elems []cty.Value - for _, ev := range list.Elements() { + elements := list.Elements() + elems := make([]cty.Value, 0, len(elements)) + for _, ev := range elements { elems = append(elems, cty.StringVal(ev.(types.String).ValueString())) } m[key] = cty.ListVal(elems) diff --git a/coreweave/object_storage/resource_bucket_test.go b/coreweave/object_storage/resource_bucket_test.go index a161d365..ebeb7b91 100644 --- a/coreweave/object_storage/resource_bucket_test.go +++ b/coreweave/object_storage/resource_bucket_test.go @@ -50,10 +50,11 @@ func createBucketTestStep(ctx context.Context, t *testing.T, opts bucketTestStep fullResourceName := fmt.Sprintf("coreweave_object_storage_bucket.%s", opts.ResourceName) - statechecks := []statecheck.StateCheck{ + statechecks := make([]statecheck.StateCheck, 0, 3) + statechecks = append(statechecks, statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("name"), knownvalue.StringExact(opts.Bucket.Name.ValueString())), statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("zone"), knownvalue.StringExact(opts.Bucket.Zone.ValueString())), - } + ) tagCheck := statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("tags"), knownvalue.Null()) diff --git a/coreweave/object_storage/resource_organization_access_policy.go b/coreweave/object_storage/resource_organization_access_policy.go index 28813eab..2bc51857 100644 --- a/coreweave/object_storage/resource_organization_access_policy.go +++ b/coreweave/object_storage/resource_organization_access_policy.go @@ -394,25 +394,25 @@ func MustRenderOrganizationAccessPolicy(ctx context.Context, resourceName string resourceBody.SetAttributeValue("name", cty.StringVal(policy.Name.ValueString())) - statements := []cty.Value{} + statements := make([]cty.Value, 0, len(policy.Statements)) for _, s := range policy.Statements { actionsSlice := []string{} s.Actions.ElementsAs(ctx, &actionsSlice, false) - actions := []cty.Value{} + actions := make([]cty.Value, 0, len(actionsSlice)) for _, a := range actionsSlice { actions = append(actions, cty.StringVal(a)) } resourcesSlice := []string{} s.Resources.ElementsAs(ctx, &resourcesSlice, false) - resources := []cty.Value{} + resources := make([]cty.Value, 0, len(resourcesSlice)) for _, a := range resourcesSlice { resources = append(resources, cty.StringVal(a)) } principalsSlice := []string{} s.Principals.ElementsAs(ctx, &principalsSlice, false) - principals := []cty.Value{} + principals := make([]cty.Value, 0, len(principalsSlice)) for _, a := range principalsSlice { principals = append(principals, cty.StringVal(a)) } diff --git a/coreweave/object_storage/resource_organization_access_policy_test.go b/coreweave/object_storage/resource_organization_access_policy_test.go index c2a85d7c..e54bfe85 100644 --- a/coreweave/object_storage/resource_organization_access_policy_test.go +++ b/coreweave/object_storage/resource_organization_access_policy_test.go @@ -49,29 +49,30 @@ func createOrgAccessPolicyTestStep(ctx context.Context, t *testing.T, opts orgAc t.Helper() fullResourceName := fmt.Sprintf("coreweave_object_storage_organization_access_policy.%s", opts.ResourceName) - statechecks := []statecheck.StateCheck{ + statechecks := make([]statecheck.StateCheck, 0, 2) + statechecks = append(statechecks, statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("name"), knownvalue.StringExact(opts.Policy.Name.ValueString())), - } + ) - statements := []knownvalue.Check{} + statements := make([]knownvalue.Check, 0, len(opts.Policy.Statements)) for _, s := range opts.Policy.Statements { actions := []string{} s.Actions.ElementsAs(ctx, &actions, false) - actionValues := []knownvalue.Check{} + actionValues := make([]knownvalue.Check, 0, len(actions)) for _, a := range actions { actionValues = append(actionValues, knownvalue.StringExact(a)) } principals := []string{} s.Principals.ElementsAs(ctx, &principals, false) - principalValues := []knownvalue.Check{} + principalValues := make([]knownvalue.Check, 0, len(principals)) for _, p := range principals { principalValues = append(principalValues, knownvalue.StringExact(p)) } resources := []string{} s.Resources.ElementsAs(ctx, &resources, false) - resourceValues := []knownvalue.Check{} + resourceValues := make([]knownvalue.Check, 0, len(resources)) for _, r := range resources { resourceValues = append(resourceValues, knownvalue.StringExact(r)) } From 311ea2d274586586dd882efcd74471500c83e5b6 Mon Sep 17 00:00:00 2001 From: Eric Miller Date: Thu, 30 Jul 2026 12:53:04 -0500 Subject: [PATCH 2/3] ci: increase acceptance sweep timeout --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index d10d3545..75edb1a0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -57,7 +57,7 @@ SUITES?=cks networking object_storage inference testacc-sweep: @for suite in $(SUITES); do \ - go test -v -timeout 10m ./coreweave/$$suite -sweep='$(TEST_ACC_SWEEP_ZONE)'; \ + go test -v -timeout 30m ./coreweave/$$suite -sweep='$(TEST_ACC_SWEEP_ZONE)'; \ done testacc: From 3d397d02d466f9bff63802b3464ab149b4a6d66b Mon Sep 17 00:00:00 2001 From: Eric Miller Date: Thu, 30 Jul 2026 14:13:20 -0500 Subject: [PATCH 3/3] chore(lint): exclude test files from prealloc --- .golangci.yaml | 1 + coreweave/cks/resource_cluster_test.go | 7 +++---- coreweave/object_storage/resource_bucket_test.go | 5 ++--- .../resource_organization_access_policy_test.go | 13 ++++++------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 40102c75..cc9f998a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -123,3 +123,4 @@ linters: - dupl - gosec - gocritic + - prealloc diff --git a/coreweave/cks/resource_cluster_test.go b/coreweave/cks/resource_cluster_test.go index b0443459..e04c5925 100644 --- a/coreweave/cks/resource_cluster_test.go +++ b/coreweave/cks/resource_cluster_test.go @@ -299,9 +299,8 @@ func createClusterTestStep(ctx context.Context, t *testing.T, config testStepCon } // internal lb cidrs - internalLbCidrNames := config.cluster.InternalLbCidrNames(ctx) - internalLbCidrs := make([]knownvalue.Check, 0, len(internalLbCidrNames)) - for _, c := range internalLbCidrNames { + internalLbCidrs := []knownvalue.Check{} + for _, c := range config.cluster.InternalLbCidrNames(ctx) { internalLbCidrs = append(internalLbCidrs, knownvalue.StringExact(c)) } statechecks = append(statechecks, statecheck.ExpectKnownValue(config.Resources.FullResourceName, tfjsonpath.New("internal_lb_cidr_names"), knownvalue.ListExact(internalLbCidrs))) @@ -328,7 +327,7 @@ func createClusterTestStep(ctx context.Context, t *testing.T, config testStepCon t.FailNow() } - checks := make([]knownvalue.Check, 0, len(algs)) + checks := []knownvalue.Check{} for _, a := range algs { checks = append(checks, knownvalue.StringExact(a.ValueString())) } diff --git a/coreweave/object_storage/resource_bucket_test.go b/coreweave/object_storage/resource_bucket_test.go index ebeb7b91..a161d365 100644 --- a/coreweave/object_storage/resource_bucket_test.go +++ b/coreweave/object_storage/resource_bucket_test.go @@ -50,11 +50,10 @@ func createBucketTestStep(ctx context.Context, t *testing.T, opts bucketTestStep fullResourceName := fmt.Sprintf("coreweave_object_storage_bucket.%s", opts.ResourceName) - statechecks := make([]statecheck.StateCheck, 0, 3) - statechecks = append(statechecks, + statechecks := []statecheck.StateCheck{ statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("name"), knownvalue.StringExact(opts.Bucket.Name.ValueString())), statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("zone"), knownvalue.StringExact(opts.Bucket.Zone.ValueString())), - ) + } tagCheck := statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("tags"), knownvalue.Null()) diff --git a/coreweave/object_storage/resource_organization_access_policy_test.go b/coreweave/object_storage/resource_organization_access_policy_test.go index e54bfe85..c2a85d7c 100644 --- a/coreweave/object_storage/resource_organization_access_policy_test.go +++ b/coreweave/object_storage/resource_organization_access_policy_test.go @@ -49,30 +49,29 @@ func createOrgAccessPolicyTestStep(ctx context.Context, t *testing.T, opts orgAc t.Helper() fullResourceName := fmt.Sprintf("coreweave_object_storage_organization_access_policy.%s", opts.ResourceName) - statechecks := make([]statecheck.StateCheck, 0, 2) - statechecks = append(statechecks, + statechecks := []statecheck.StateCheck{ statecheck.ExpectKnownValue(fullResourceName, tfjsonpath.New("name"), knownvalue.StringExact(opts.Policy.Name.ValueString())), - ) + } - statements := make([]knownvalue.Check, 0, len(opts.Policy.Statements)) + statements := []knownvalue.Check{} for _, s := range opts.Policy.Statements { actions := []string{} s.Actions.ElementsAs(ctx, &actions, false) - actionValues := make([]knownvalue.Check, 0, len(actions)) + actionValues := []knownvalue.Check{} for _, a := range actions { actionValues = append(actionValues, knownvalue.StringExact(a)) } principals := []string{} s.Principals.ElementsAs(ctx, &principals, false) - principalValues := make([]knownvalue.Check, 0, len(principals)) + principalValues := []knownvalue.Check{} for _, p := range principals { principalValues = append(principalValues, knownvalue.StringExact(p)) } resources := []string{} s.Resources.ElementsAs(ctx, &resources, false) - resourceValues := make([]knownvalue.Check, 0, len(resources)) + resourceValues := []knownvalue.Check{} for _, r := range resources { resourceValues = append(resourceValues, knownvalue.StringExact(r)) }