Skip to content

Commit

Permalink
refactor: replace experimental maps and slices with stdlib (#6372)
Browse files Browse the repository at this point in the history
Signed-off-by: Eng Zer Jun <[email protected]>
Signed-off-by: Jan Wozniak <[email protected]>
Co-authored-by: Jan Wozniak <[email protected]>
  • Loading branch information
Juneezee and wozniakjan authored Dec 4, 2024
1 parent 1eaa34c commit c8be1c7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ New deprecation(s):
### Other

- **General**: Bump newrelic-client-go deps to 2.51.2 (latest) ([#6325](https://github.com/kedacore/keda/pull/6325))
- **General**: refactor: replace experimental `maps` and `slices` with stdlib ([#6372](https://github.com/kedacore/keda/pull/6372))


## v2.16.0
Expand Down
2 changes: 1 addition & 1 deletion apis/eventing/v1alpha1/cloudeventsource_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package v1alpha1
import (
"encoding/json"
"fmt"
"slices"

"golang.org/x/exp/slices"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/kedacore/keda/v2

go 1.22.1

toolchain go1.23.3
go 1.23.3

require (
cloud.google.com/go/compute/metadata v0.5.2
Expand Down Expand Up @@ -347,7 +345,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.28.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/eventemitter/eventfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package eventemitter

import (
"golang.org/x/exp/slices"
"slices"

eventingv1alpha1 "github.com/kedacore/keda/v2/apis/eventing/v1alpha1"
)
Expand Down
11 changes: 4 additions & 7 deletions pkg/scalers/scalersconfig/typed_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"net/url"
"reflect"
"runtime/debug"
"slices"
"strconv"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

// CustomValidator is an interface that can be implemented to validate the configuration of the typed config
Expand Down Expand Up @@ -204,8 +203,7 @@ func (sc *ScalerConfig) setValue(field reflect.Value, params Params) error {
}
if !exists && !(params.Optional || params.IsDeprecated()) {
if len(params.Order) == 0 {
apo := maps.Keys(allowedParsingOrderMap)
slices.Sort(apo)
apo := slices.Sorted(maps.Keys(allowedParsingOrderMap))
return fmt.Errorf("missing required parameter %q, no 'order' tag, provide any from %v", params.Name(), apo)
}
return fmt.Errorf("missing required parameter %q in %v", params.Name(), params.Order)
Expand Down Expand Up @@ -463,8 +461,7 @@ func paramsFromTag(tag string, field reflect.StructField) (Params, error) {
for _, po := range order {
poTyped := ParsingOrder(strings.TrimSpace(po))
if !allowedParsingOrderMap[poTyped] {
apo := maps.Keys(allowedParsingOrderMap)
slices.Sort(apo)
apo := slices.Sorted(maps.Keys(allowedParsingOrderMap))
return params, fmt.Errorf("unknown parsing order value %s, has to be one of %s", po, apo)
}
params.Order = append(params.Order, poTyped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"maps"
"os/exec"
"slices"
"strings"
"testing"
"time"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/prometheus/common/expfmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down

0 comments on commit c8be1c7

Please sign in to comment.