Skip to content

Commit a1d843e

Browse files
committed
prealloc suddenly complained about new issues
On-behalf-of: @SAP [email protected]
1 parent 44d7239 commit a1d843e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

cmd/sharded-test-server/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func start(proxyFlags, shardFlags []string, logDirPath, workDirPath string, numb
216216
}
217217

218218
// start shards
219-
var shards []*testshard.Shard
219+
shards := make([]*testshard.Shard, numberOfShards)
220220
for i := range numberOfShards {
221221
shard, err := newShard(ctx, i, shardFlags, standaloneVW, servingCA, hostIP.String(), logDirPath, workDirPath, cacheServerConfigPath, clientCA)
222222
if err != nil {
@@ -225,7 +225,7 @@ func start(proxyFlags, shardFlags []string, logDirPath, workDirPath string, numb
225225
if err := shard.Start(ctx, quiet); err != nil {
226226
return err
227227
}
228-
shards = append(shards, shard)
228+
shards[i] = shard
229229
}
230230

231231
// Start virtual-workspace servers

pkg/virtual/framework/forwardingregistry/store_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ func TestUpdateToCreateOptions(t *testing.T) {
3030
numField := updateOptions.NumField()
3131
require.Equalf(t, 4, numField, "UpdateOptions is expected to have 4 fields")
3232

33-
var fields []string
33+
fields := make([]string, numField)
3434
for i := range numField {
35-
fields = append(fields, updateOptions.Field(i).Name)
35+
fields[i] = updateOptions.Field(i).Name
3636
}
3737

3838
// Assert the UpdateOptions struct fields set has not changed

test/e2e/virtual/apiexport/virtualworkspace_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,9 +1125,11 @@ func newCowboy(namespace, name string) *wildwestv1alpha1.Cowboy {
11251125
}
11261126

11271127
func createClusterRoleAndBindings(name, subjectName, subjectKind string, verbs []string, resources ...string) (*rbacv1.ClusterRole, *rbacv1.ClusterRoleBinding) {
1128-
var rules []rbacv1.PolicyRule
1128+
var total = len(resources) / 3
11291129

1130-
for i := range len(resources) / 3 {
1130+
rules := make([]rbacv1.PolicyRule, total)
1131+
1132+
for i := range total {
11311133
group := resources[i*3]
11321134
resource := resources[i*3+1]
11331135
resourceName := resources[i*3+2]
@@ -1142,7 +1144,7 @@ func createClusterRoleAndBindings(name, subjectName, subjectKind string, verbs [
11421144
r.ResourceNames = []string{resourceName}
11431145
}
11441146

1145-
rules = append(rules, r)
1147+
rules[i] = r
11461148
}
11471149

11481150
return &rbacv1.ClusterRole{

0 commit comments

Comments
 (0)