diff --git a/.golangci.yaml b/.golangci.yaml index 4d4e5a8a..cc9f998a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -23,7 +23,7 @@ linters: - revive - makezero - nakedret - # - prealloc + - prealloc - nolintlint - staticcheck - thelper @@ -123,3 +123,4 @@ linters: - dupl - gosec - gocritic + - prealloc 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: 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_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)) }