From 1eb75721bdca01fc60a385f76c33ff914792f6e0 Mon Sep 17 00:00:00 2001 From: "x.zhou" Date: Tue, 8 Oct 2024 11:53:36 +0800 Subject: [PATCH] chore: get rid of golang.org/x/exp/{constraints,slices} modules --- .../v1alpha1/opsrequest_validation.go | 2 +- controllers/apps/cluster_controller_test.go | 2 +- controllers/apps/cluster_status_conditions.go | 2 +- .../apps/clusterdefinition_controller.go | 2 +- .../apps/componentdefinition_controller.go | 2 +- .../apps/configuration/reconfigure_policy.go | 6 +-- .../configuration/rolling_upgrade_policy.go | 3 +- .../apps/transformer_cluster_backup_policy.go | 2 +- .../apps/transformer_cluster_service_test.go | 12 +++-- ...transformer_component_account_provision.go | 2 +- .../transformer_component_service_test.go | 15 +++--- .../apps/transformer_component_workload.go | 2 +- .../log_collection_controller.go | 6 +-- .../volumepopulator_controller.go | 2 +- .../reconciler_scale_target_cluster.go | 2 +- .../experimental/reconciler_update_status.go | 2 +- .../extensions/addon_controller_stages.go | 6 +-- .../operations/opsrequest_controller.go | 2 +- .../operations/opsrequest_controller_test.go | 2 +- go.mod | 2 - go.sum | 38 ++++++++++---- pkg/configuration/util/math.go | 16 ------ pkg/configuration/util/math_test.go | 49 ------------------- pkg/controller/component/component_version.go | 2 +- pkg/controller/component/service_reference.go | 2 +- .../instanceset/in_place_update_util.go | 2 +- .../reconciler_instance_alignment_test.go | 2 +- .../instanceset/reconciler_update_test.go | 2 +- .../kubebuilderx/plan_builder_test.go | 2 +- pkg/controllerutil/util.go | 2 +- pkg/controllerutil/util_test.go | 7 +-- pkg/operations/ops_progress_util.go | 2 +- pkg/operations/ops_util.go | 2 +- pkg/operations/queue_util.go | 2 +- pkg/operations/rebuild_instance.go | 6 +-- pkg/operations/rebuild_instance_test.go | 2 +- pkg/operations/stop.go | 2 +- 37 files changed, 86 insertions(+), 130 deletions(-) diff --git a/apis/operations/v1alpha1/opsrequest_validation.go b/apis/operations/v1alpha1/opsrequest_validation.go index fd4bde7341b..f6a5c9b2d37 100644 --- a/apis/operations/v1alpha1/opsrequest_validation.go +++ b/apis/operations/v1alpha1/opsrequest_validation.go @@ -20,10 +20,10 @@ import ( "context" "encoding/json" "fmt" + "slices" "strings" "github.com/pkg/errors" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/apps/cluster_controller_test.go b/controllers/apps/cluster_controller_test.go index 4ee54d2ae27..ed5a92b8956 100644 --- a/controllers/apps/cluster_controller_test.go +++ b/controllers/apps/cluster_controller_test.go @@ -22,12 +22,12 @@ package apps import ( "encoding/json" "fmt" + "slices" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/sethvargo/go-password/password" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/apps/cluster_status_conditions.go b/controllers/apps/cluster_status_conditions.go index f1e2d01444d..55159be0f40 100644 --- a/controllers/apps/cluster_status_conditions.go +++ b/controllers/apps/cluster_status_conditions.go @@ -21,9 +21,9 @@ package apps import ( "fmt" + "slices" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/apps/clusterdefinition_controller.go b/controllers/apps/clusterdefinition_controller.go index 5b1133930c3..4006e7e2631 100644 --- a/controllers/apps/clusterdefinition_controller.go +++ b/controllers/apps/clusterdefinition_controller.go @@ -22,9 +22,9 @@ package apps import ( "context" "fmt" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" k8sruntime "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" diff --git a/controllers/apps/componentdefinition_controller.go b/controllers/apps/componentdefinition_controller.go index 2c8adfcbea5..60230d9fc5b 100644 --- a/controllers/apps/componentdefinition_controller.go +++ b/controllers/apps/componentdefinition_controller.go @@ -25,10 +25,10 @@ import ( "fmt" "hash/fnv" "reflect" + "slices" "strings" "github.com/pkg/errors" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" diff --git a/controllers/apps/configuration/reconfigure_policy.go b/controllers/apps/configuration/reconfigure_policy.go index 854189fb7f7..b487051e5dc 100644 --- a/controllers/apps/configuration/reconfigure_policy.go +++ b/controllers/apps/configuration/reconfigure_policy.go @@ -184,9 +184,9 @@ func (param *reconfigureParams) maxRollingReplicas() int32 { if isPercentage { r = int32(math.Floor(float64(v) * float64(replicas) / 100)) } else { - r = util.Safe2Int32(util.Min(v, param.getTargetReplicas())) + r = util.Safe2Int32(min(v, param.getTargetReplicas())) } - return util.Max(r, defaultRolling) + return max(r, defaultRolling) } func (param *reconfigureParams) getTargetReplicas() int { @@ -195,7 +195,7 @@ func (param *reconfigureParams) getTargetReplicas() int { func (param *reconfigureParams) podMinReadySeconds() int32 { minReadySeconds := param.SynthesizedComponent.MinReadySeconds - return util.Max(minReadySeconds, viper.GetInt32(constant.PodMinReadySecondsEnv)) + return max(minReadySeconds, viper.GetInt32(constant.PodMinReadySecondsEnv)) } func RegisterPolicy(policy appsv1alpha1.UpgradePolicy, action reconfigurePolicy) { diff --git a/controllers/apps/configuration/rolling_upgrade_policy.go b/controllers/apps/configuration/rolling_upgrade_policy.go index 3c0d053562d..2d8165ffdca 100644 --- a/controllers/apps/configuration/rolling_upgrade_policy.go +++ b/controllers/apps/configuration/rolling_upgrade_policy.go @@ -27,7 +27,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - "github.com/apecloud/kubeblocks/pkg/configuration/util" "github.com/apecloud/kubeblocks/pkg/constant" podutil "github.com/apecloud/kubeblocks/pkg/controllerutil" viper "github.com/apecloud/kubeblocks/pkg/viperx" @@ -151,7 +150,7 @@ func markDynamicCursor(pods []corev1.Pod, podsStats *componentPodStats, configKe podsStats.updated[pod.Name] = pod } - podWindows.begin = util.Max[int](podWindows.end-int(rollingReplicas), 0) + podWindows.begin = max(podWindows.end-int(rollingReplicas), 0) for i := podWindows.begin; i < podWindows.end; i++ { pod := &pods[i] if podutil.IsMatchConfigVersion(pod, configKey, currentVersion) { diff --git a/controllers/apps/transformer_cluster_backup_policy.go b/controllers/apps/transformer_cluster_backup_policy.go index 72978b2af77..20a4b98e8d8 100644 --- a/controllers/apps/transformer_cluster_backup_policy.go +++ b/controllers/apps/transformer_cluster_backup_policy.go @@ -22,9 +22,9 @@ package apps import ( "encoding/json" "fmt" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/gengo/examples/set-gen/sets" diff --git a/controllers/apps/transformer_cluster_service_test.go b/controllers/apps/transformer_cluster_service_test.go index 44d513a4ddc..309296a7dc0 100644 --- a/controllers/apps/transformer_cluster_service_test.go +++ b/controllers/apps/transformer_cluster_service_test.go @@ -20,10 +20,12 @@ along with this program. If not, see . package apps import ( + "slices" + "strings" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -113,8 +115,8 @@ var _ = Describe("cluster service transformer test", func() { graphCli := transCtx.Client.(model.GraphClient) objs := graphCli.FindAll(dag, &corev1.Service{}) Expect(len(objs)).Should(Equal(len(reader.objs))) - slices.SortFunc(objs, func(a, b client.Object) bool { - return a.GetName() < b.GetName() + slices.SortFunc(objs, func(a, b client.Object) int { + return strings.Compare(a.GetName(), b.GetName()) }) for i := 0; i < len(reader.objs); i++ { svc := objs[i].(*corev1.Service) @@ -149,8 +151,8 @@ var _ = Describe("cluster service transformer test", func() { for i := 0; i < len(transCtx.Cluster.Spec.Services); i++ { svc := objs[i].(*corev1.Service) - slices.SortFunc(svc.Spec.Ports, func(a, b corev1.ServicePort) bool { return a.Name < b.Name }) - slices.SortFunc(expectedPorts, func(a, b corev1.ServicePort) bool { return a.Name < b.Name }) + slices.SortFunc(svc.Spec.Ports, func(a, b corev1.ServicePort) int { return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(expectedPorts, func(a, b corev1.ServicePort) int { return strings.Compare(a.Name, b.Name) }) Expect(svc.Spec.Ports).Should(Equal(expectedPorts)) Expect(graphCli.IsAction(dag, svc, model.ActionUpdatePtr())).Should(BeTrue()) } diff --git a/controllers/apps/transformer_component_account_provision.go b/controllers/apps/transformer_component_account_provision.go index afc6c7aff1c..dad5e8c8688 100644 --- a/controllers/apps/transformer_component_account_provision.go +++ b/controllers/apps/transformer_component_account_provision.go @@ -20,9 +20,9 @@ along with this program. If not, see . package apps import ( + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/controllers/apps/transformer_component_service_test.go b/controllers/apps/transformer_component_service_test.go index 6b7eaea7035..8d53e8c727e 100644 --- a/controllers/apps/transformer_component_service_test.go +++ b/controllers/apps/transformer_component_service_test.go @@ -21,11 +21,12 @@ package apps import ( "fmt" + "slices" + "strings" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -133,8 +134,8 @@ var _ = Describe(" component service transformer test", func() { graphCli := transCtx.Client.(model.GraphClient) objs := graphCli.FindAll(dag, &corev1.Service{}) Expect(len(objs)).Should(Equal(int(transCtx.SynthesizeComponent.Replicas))) - slices.SortFunc(objs, func(a, b client.Object) bool { - return a.GetName() < b.GetName() + slices.SortFunc(objs, func(a, b client.Object) int { + return strings.Compare(a.GetName(), b.GetName()) }) for i := int32(0); i < transCtx.SynthesizeComponent.Replicas; i++ { svc := objs[i].(*corev1.Service) @@ -160,8 +161,8 @@ var _ = Describe(" component service transformer test", func() { graphCli := transCtx.Client.(model.GraphClient) objs := graphCli.FindAll(dag, &corev1.Service{}) Expect(len(objs)).Should(Equal(int(transCtx.SynthesizeComponent.Replicas))) - slices.SortFunc(objs, func(a, b client.Object) bool { - return a.GetName() < b.GetName() + slices.SortFunc(objs, func(a, b client.Object) int { + return strings.Compare(a.GetName(), b.GetName()) }) for i := int32(0); i < transCtx.SynthesizeComponent.Replicas; i++ { svc := objs[i].(*corev1.Service) @@ -188,8 +189,8 @@ var _ = Describe(" component service transformer test", func() { graphCli := transCtx.Client.(model.GraphClient) objs := graphCli.FindAll(dag, &corev1.Service{}) Expect(len(objs)).Should(Equal(int(replicas))) - slices.SortFunc(objs, func(a, b client.Object) bool { - return a.GetName() < b.GetName() + slices.SortFunc(objs, func(a, b client.Object) int { + return strings.Compare(a.GetName(), b.GetName()) }) for i := int32(0); i < replicas; i++ { svc := objs[i].(*corev1.Service) diff --git a/controllers/apps/transformer_component_workload.go b/controllers/apps/transformer_component_workload.go index 50d17998e07..34da19cf1c8 100644 --- a/controllers/apps/transformer_component_workload.go +++ b/controllers/apps/transformer_component_workload.go @@ -24,11 +24,11 @@ import ( "errors" "fmt" "reflect" + "slices" "strings" "github.com/spf13/viper" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" diff --git a/controllers/dataprotection/log_collection_controller.go b/controllers/dataprotection/log_collection_controller.go index e361aedd8f9..a3726012ad5 100644 --- a/controllers/dataprotection/log_collection_controller.go +++ b/controllers/dataprotection/log_collection_controller.go @@ -22,10 +22,10 @@ package dataprotection import ( "context" "fmt" + "slices" "strings" "github.com/spf13/viper" - "golang.org/x/exp/slices" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" k8sruntime "k8s.io/apimachinery/pkg/runtime" @@ -136,8 +136,8 @@ func (r *LogCollectionReconciler) collectErrorLogs(reqCtx intctrlutil.RequestCtx return "", nil } // sort pod with oldest creation place front - slices.SortFunc(podList.Items, func(a, b corev1.Pod) bool { - return !b.CreationTimestamp.Before(&(a.CreationTimestamp)) + slices.SortFunc(podList.Items, func(a, b corev1.Pod) int { + return b.CreationTimestamp.Compare(a.CreationTimestamp.Time) }) oldestPod := podList.Items[0] clientset, err := corev1client.NewForConfig(r.RestConfig) diff --git a/controllers/dataprotection/volumepopulator_controller.go b/controllers/dataprotection/volumepopulator_controller.go index 421fee22f0e..f95be89d707 100644 --- a/controllers/dataprotection/volumepopulator_controller.go +++ b/controllers/dataprotection/volumepopulator_controller.go @@ -22,10 +22,10 @@ package dataprotection import ( "context" "fmt" + "slices" "strings" vsv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" - "golang.org/x/exp/slices" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" diff --git a/controllers/experimental/reconciler_scale_target_cluster.go b/controllers/experimental/reconciler_scale_target_cluster.go index f492d97480d..1d166471620 100644 --- a/controllers/experimental/reconciler_scale_target_cluster.go +++ b/controllers/experimental/reconciler_scale_target_cluster.go @@ -20,9 +20,9 @@ along with this program. If not, see . package experimental import ( + "slices" "time" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/experimental/reconciler_update_status.go b/controllers/experimental/reconciler_update_status.go index 22ba0bcc19d..dd1671a247f 100644 --- a/controllers/experimental/reconciler_update_status.go +++ b/controllers/experimental/reconciler_update_status.go @@ -21,9 +21,9 @@ package experimental import ( "fmt" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/extensions/addon_controller_stages.go b/controllers/extensions/addon_controller_stages.go index 9e37c95514a..e8f0aa7031b 100644 --- a/controllers/extensions/addon_controller_stages.go +++ b/controllers/extensions/addon_controller_stages.go @@ -23,12 +23,12 @@ import ( "context" "encoding/json" "fmt" + "slices" "strings" "time" "github.com/Masterminds/semver/v3" ctrlerihandler "github.com/authzed/controller-idioms/handler" - "golang.org/x/exp/slices" v1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -1101,8 +1101,8 @@ func logFailedJobPodToCondError(ctx context.Context, stageCtx *stageCtx, addon * } // sort pod with latest creation place front - slices.SortFunc(podList.Items, func(a, b corev1.Pod) bool { - return b.CreationTimestamp.Before(&(a.CreationTimestamp)) + slices.SortFunc(podList.Items, func(a, b corev1.Pod) int { + return b.CreationTimestamp.Compare(a.CreationTimestamp.Time) }) podsloop: diff --git a/controllers/operations/opsrequest_controller.go b/controllers/operations/opsrequest_controller.go index 6672688ac33..b6e02d8554c 100644 --- a/controllers/operations/opsrequest_controller.go +++ b/controllers/operations/opsrequest_controller.go @@ -23,10 +23,10 @@ import ( "context" "math" "reflect" + "slices" "strings" "time" - "golang.org/x/exp/slices" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/operations/opsrequest_controller_test.go b/controllers/operations/opsrequest_controller_test.go index 06d99e4eb10..4818db972aa 100644 --- a/controllers/operations/opsrequest_controller_test.go +++ b/controllers/operations/opsrequest_controller_test.go @@ -22,13 +22,13 @@ package operations import ( "fmt" "reflect" + "slices" "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/resource" diff --git a/go.mod b/go.mod index 92b562bb37c..f4cf6e6d7e8 100644 --- a/go.mod +++ b/go.mod @@ -246,5 +246,3 @@ require ( sigs.k8s.io/kustomize/kyaml v0.14.3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) - -replace golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb diff --git a/go.sum b/go.sum index 7de2e547ae1..798018d6657 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,7 @@ cuelabs.dev/go/oci/ociregistry v0.0.0-20240314152124-224736b49f2e h1:GwCVItFUPxw cuelabs.dev/go/oci/ociregistry v0.0.0-20240314152124-224736b49f2e/go.mod h1:ApHceQLLwcOkCEXM1+DyCXTHEJhNGDpJ2kmV6axsx24= cuelang.org/go v0.8.0 h1:fO1XPe/SUGtc7dhnGnTPbpIDoQm/XxhDtoSF7jzO01c= cuelang.org/go v0.8.0/go.mod h1:CoDbYolfMms4BhWUlhD+t5ORnihR7wvjcfgyO9lL5FI= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -62,6 +63,7 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= @@ -259,6 +261,9 @@ github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2H github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gorp/gorp/v3 v3.0.5 h1:PUjzYdYu3HBOh8LE+UUmRG2P0IRDak9XMeGNvaeq4Ow= github.com/go-gorp/gorp/v3 v3.0.5/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -380,7 +385,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -933,13 +937,24 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= -golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -952,16 +967,18 @@ golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1011,7 +1028,6 @@ golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= @@ -1053,6 +1069,7 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1062,6 +1079,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1119,7 +1137,6 @@ golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= @@ -1151,6 +1168,7 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1160,7 +1178,9 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1175,6 +1195,7 @@ golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1205,7 +1226,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/configuration/util/math.go b/pkg/configuration/util/math.go index 9769ae674c9..23736da8ac4 100644 --- a/pkg/configuration/util/math.go +++ b/pkg/configuration/util/math.go @@ -21,24 +21,8 @@ package util import ( "math" - - "golang.org/x/exp/constraints" ) -func Min[T constraints.Ordered](l, r T) T { - if l < r { - return l - } - return r -} - -func Max[T constraints.Ordered](l, r T) T { - if l < r { - return r - } - return l -} - func Safe2Int32(v int) int32 { switch { default: diff --git a/pkg/configuration/util/math_test.go b/pkg/configuration/util/math_test.go index a435905c236..b78af5e3c3f 100644 --- a/pkg/configuration/util/math_test.go +++ b/pkg/configuration/util/math_test.go @@ -21,58 +21,9 @@ package util import ( "math" - "reflect" "testing" - - "golang.org/x/exp/constraints" ) -type sData[T constraints.Ordered] [2]T - -func makeTestData[T constraints.Ordered](l, r T) sData[T] { - var data sData[T] - data[0] = l - data[1] = r - return data -} - -func testGenericType[T constraints.Ordered](t *testing.T, data []sData[T], expected []int) { - for i := 0; i < len(expected); i++ { - t.Run("test", func(t *testing.T) { - if got := Min[T](data[i][0], data[i][1]); !reflect.DeepEqual(got, data[i][expected[i]]) { - t.Errorf("Min() = %v, want %v", got, expected[i]) - } - if got := Max[T](data[i][0], data[i][1]); !reflect.DeepEqual(got, data[i][1-expected[i]]) { - t.Errorf("Min() = %v, want %v", got, expected[i]) - } - }) - } -} - -func TestMin(t *testing.T) { - testGenericType(t, []sData[int]{ - makeTestData(1, 2), - makeTestData(2, 1), - makeTestData(1, 1), - }, []int{0, 1, 0}) - - testGenericType(t, []sData[float64]{ - makeTestData(1.1, 2.2), - makeTestData(2.0, 1.2), - makeTestData(1.0, 1.0), - }, []int{0, 1, 0}) - - testGenericType(t, []sData[string]{ - makeTestData("abc", "ab"), - makeTestData("efg", "efge"), - makeTestData("a", "b"), - makeTestData("b", "a"), - makeTestData("", "a"), - makeTestData("ab", ""), - makeTestData("", ""), - }, []int{1, 0, 0, 1, 0, 1, 0}) -} - func TestSafe2Int32(t *testing.T) { tests := []struct { name string diff --git a/pkg/controller/component/component_version.go b/pkg/controller/component/component_version.go index 3782881ffaa..8e352d5c3e5 100644 --- a/pkg/controller/component/component_version.go +++ b/pkg/controller/component/component_version.go @@ -22,9 +22,9 @@ package component import ( "context" "fmt" + "slices" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/version" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controller/component/service_reference.go b/pkg/controller/component/service_reference.go index f3e4c286f82..9368941f43d 100644 --- a/pkg/controller/component/service_reference.go +++ b/pkg/controller/component/service_reference.go @@ -23,9 +23,9 @@ import ( "context" "fmt" "regexp" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controller/instanceset/in_place_update_util.go b/pkg/controller/instanceset/in_place_update_util.go index 2070e85d757..7bd7732ed32 100644 --- a/pkg/controller/instanceset/in_place_update_util.go +++ b/pkg/controller/instanceset/in_place_update_util.go @@ -22,9 +22,9 @@ package instanceset import ( "fmt" "reflect" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/pkg/controller/instanceset/reconciler_instance_alignment_test.go b/pkg/controller/instanceset/reconciler_instance_alignment_test.go index 9b89563c9ce..4eb392d15b6 100644 --- a/pkg/controller/instanceset/reconciler_instance_alignment_test.go +++ b/pkg/controller/instanceset/reconciler_instance_alignment_test.go @@ -21,11 +21,11 @@ package instanceset import ( "fmt" + "slices" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/controller/instanceset/reconciler_update_test.go b/pkg/controller/instanceset/reconciler_update_test.go index 6d26f39c5d7..222425794e6 100644 --- a/pkg/controller/instanceset/reconciler_update_test.go +++ b/pkg/controller/instanceset/reconciler_update_test.go @@ -20,12 +20,12 @@ along with this program. If not, see . package instanceset import ( + "slices" "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/kubebuilderx/plan_builder_test.go b/pkg/controller/kubebuilderx/plan_builder_test.go index 439cd51956f..72a970ab4ef 100644 --- a/pkg/controller/kubebuilderx/plan_builder_test.go +++ b/pkg/controller/kubebuilderx/plan_builder_test.go @@ -22,12 +22,12 @@ package kubebuilderx import ( "context" "reflect" + "slices" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/golang/mock/gomock" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controllerutil/util.go b/pkg/controllerutil/util.go index 4b161a7f1c6..dd01b9ba6b5 100644 --- a/pkg/controllerutil/util.go +++ b/pkg/controllerutil/util.go @@ -24,9 +24,9 @@ import ( "fmt" "reflect" gruntime "runtime" + "slices" "strings" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/controllerutil/util_test.go b/pkg/controllerutil/util_test.go index 40093458320..725e8888c5a 100644 --- a/pkg/controllerutil/util_test.go +++ b/pkg/controllerutil/util_test.go @@ -21,12 +21,13 @@ package controllerutil import ( "context" + "slices" + "strings" "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/record" ) @@ -77,8 +78,8 @@ var _ = Describe("utils test", func() { }) Expect(dst).Should(HaveLen(3)) - slices.SortStableFunc(dst, func(a, b corev1.Volume) bool { - return a.Name < b.Name + slices.SortStableFunc(dst, func(a, b corev1.Volume) int { + return strings.Compare(a.Name, b.Name) }) Expect(dst[0].Name).Should(Equal("pvc0")) Expect(dst[1].Name).Should(Equal("pvc1")) diff --git a/pkg/operations/ops_progress_util.go b/pkg/operations/ops_progress_util.go index ef4e93685b5..e0c02f8bd84 100644 --- a/pkg/operations/ops_progress_util.go +++ b/pkg/operations/ops_progress_util.go @@ -22,10 +22,10 @@ package operations import ( "fmt" "reflect" + "slices" "strings" "time" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" diff --git a/pkg/operations/ops_util.go b/pkg/operations/ops_util.go index dc69c5b73b9..5c59f7fe9d7 100644 --- a/pkg/operations/ops_util.go +++ b/pkg/operations/ops_util.go @@ -22,9 +22,9 @@ package operations import ( "context" "fmt" + "slices" "time" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/operations/queue_util.go b/pkg/operations/queue_util.go index 7bbb007e0e9..d4a51b40f6d 100644 --- a/pkg/operations/queue_util.go +++ b/pkg/operations/queue_util.go @@ -22,9 +22,9 @@ package operations import ( "context" "fmt" + "slices" "time" - "golang.org/x/exp/slices" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/operations/rebuild_instance.go b/pkg/operations/rebuild_instance.go index c3b4b8208b1..ff5f5420de6 100644 --- a/pkg/operations/rebuild_instance.go +++ b/pkg/operations/rebuild_instance.go @@ -23,10 +23,10 @@ import ( "context" "fmt" "reflect" + "slices" "strings" "time" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -330,8 +330,8 @@ func (r rebuildInstanceOpsHandler) scaleOutRequiredInstances(reqCtx intctrlutil. rebuildInstance opsv1alpha1.RebuildInstance, compStatus *opsv1alpha1.OpsRequestComponentStatus) error { // 1. sort the instances - slices.SortFunc(rebuildInstance.Instances, func(a, b opsv1alpha1.Instance) bool { - return a.Name < b.Name + slices.SortFunc(rebuildInstance.Instances, func(a, b opsv1alpha1.Instance) int { + return strings.Compare(a.Name, b.Name) }) // 2. assemble the corresponding replicas and instances based on the template diff --git a/pkg/operations/rebuild_instance_test.go b/pkg/operations/rebuild_instance_test.go index eb9bc92d7de..0fc50022485 100644 --- a/pkg/operations/rebuild_instance_test.go +++ b/pkg/operations/rebuild_instance_test.go @@ -21,11 +21,11 @@ package operations import ( "fmt" + "slices" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/operations/stop.go b/pkg/operations/stop.go index 0462d4ce807..44b945c4b73 100644 --- a/pkg/operations/stop.go +++ b/pkg/operations/stop.go @@ -20,9 +20,9 @@ along with this program. If not, see . package operations import ( + "slices" "time" - "golang.org/x/exp/slices" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client"