Skip to content

Commit fe2962b

Browse files
pierreprinettimdbooth
authored andcommitted
CARRY: Revert to Go v1.21
1 parent 4e7fd29 commit fe2962b

File tree

7 files changed

+29
-9
lines changed

7 files changed

+29
-9
lines changed

api/v1alpha6/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package v1alpha6
1818

1919
import (
20-
"slices"
2120
"testing"
2221

2322
"github.com/google/go-cmp/cmp"
@@ -32,6 +31,7 @@ import (
3231
"sigs.k8s.io/controller-runtime/pkg/conversion"
3332

3433
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
34+
"sigs.k8s.io/cluster-api-provider-openstack/internal/futures"
3535
testhelpers "sigs.k8s.io/cluster-api-provider-openstack/test/helpers"
3636
)
3737

@@ -123,7 +123,7 @@ func TestFuzzyConversion(t *testing.T) {
123123
},
124124
}
125125

126-
return slices.Concat(v1alpha6FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())
126+
return futures.SlicesConcat(v1alpha6FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())
127127
}
128128

129129
t.Run("for OpenStackCluster", runParallel(utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{

api/v1alpha7/conversion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package v1alpha7
1818

1919
import (
20-
"slices"
2120
"testing"
2221

2322
"github.com/google/go-cmp/cmp"
@@ -32,6 +31,7 @@ import (
3231
"sigs.k8s.io/controller-runtime/pkg/conversion"
3332

3433
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
34+
"sigs.k8s.io/cluster-api-provider-openstack/internal/futures"
3535
testhelpers "sigs.k8s.io/cluster-api-provider-openstack/test/helpers"
3636
)
3737

@@ -91,7 +91,7 @@ func TestFuzzyConversion(t *testing.T) {
9191
},
9292
}
9393

94-
return slices.Concat(v1alpha7FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())
94+
return futures.SlicesConcat(v1alpha7FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())
9595
}
9696

9797
t.Run("for OpenStackCluster", runParallel(utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/cluster-api-provider-openstack
22

3-
go 1.22
3+
go 1.21
44

55
require (
66
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc

hack/tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/cluster-api-provider-openstack/hack/tools
22

3-
go 1.22
3+
go 1.21
44

55
require (
66
github.com/a8m/envsubst v1.2.0

internal/futures/slices.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package futures
2+
3+
import stdlib_slices "slices"
4+
5+
// SlicesConcat vendors the Go v1.22 slices.Concat function.
6+
func SlicesConcat[S ~[]E, E any](slices ...S) S {
7+
size := 0
8+
for _, s := range slices {
9+
size += len(s)
10+
if size < 0 {
11+
panic("len out of range")
12+
}
13+
}
14+
newslice := stdlib_slices.Grow[S](nil, size)
15+
for _, s := range slices {
16+
newslice = append(newslice, s...)
17+
}
18+
return newslice
19+
}

pkg/cloud/services/compute/referenced_resources.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"slices"
2222

2323
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
24+
"sigs.k8s.io/cluster-api-provider-openstack/internal/futures"
2425
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/networking"
2526
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
2627
)
@@ -89,7 +90,7 @@ func ResolveMachineSpec(scope *scope.WithLogger, spec *infrav1.OpenStackMachineS
8990
// The tags are a deduplicated combination of the tags specified in the
9091
// OpenStackMachineSpec and the ones specified on the OpenStackCluster.
9192
func InstanceTags(spec *infrav1.OpenStackMachineSpec, openStackCluster *infrav1.OpenStackCluster) []string {
92-
machineTags := slices.Concat(spec.Tags, openStackCluster.Spec.Tags)
93+
machineTags := futures.SlicesConcat(spec.Tags, openStackCluster.Spec.Tags)
9394

9495
seen := make(map[string]struct{}, len(machineTags))
9596
unique := make([]string, 0, len(machineTags))

pkg/cloud/services/networking/port.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"slices"
2423
"strings"
2524
"time"
2625

@@ -33,6 +32,7 @@ import (
3332
"k8s.io/utils/ptr"
3433

3534
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
35+
"sigs.k8s.io/cluster-api-provider-openstack/internal/futures"
3636
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
3737
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
3838
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
@@ -427,7 +427,7 @@ func (s *Service) normalizePorts(ports []infrav1.PortOpts, clusterResourceName,
427427
}
428428

429429
// Tags are inherited base tags plus any port-specific tags
430-
normalizedPort.Tags = slices.Concat(baseTags, port.Tags)
430+
normalizedPort.Tags = futures.SlicesConcat(baseTags, port.Tags)
431431

432432
// No Trunk field specified for the port, inherit the machine default
433433
if port.Trunk == nil {

0 commit comments

Comments
 (0)