Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor scalers package and move ScalersConfig #5381

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ issues:
linters:
- gomnd
- dupl
- revive
- goconst
- path: scalers_builder.go
linters:
- gocyclo
Expand Down Expand Up @@ -146,6 +148,7 @@ issues:
- path: controllers/keda/scaledobject_controller_test.go
linters:
- depguard
- goconst
- path: pkg/scalers/external_scaler_test.go
linters:
- depguard
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ New deprecation(s):
- **General**: Fix lost commit from the newly created utility function ([#5037](https://github.com/kedacore/keda/issues/5037))
- **General**: Improve docker image build time through caches ([#5316](https://github.com/kedacore/keda/issues/5316))
- **General**: Reduce amount of gauge creations for OpenTelemetry metrics ([#5101](https://github.com/kedacore/keda/issues/5101))
- **General**: Refactor `scalers` package ([#5379](https://github.com/kedacore/keda/issues/5379))
- **General**: Removed not required RBAC permissions ([#5261](https://github.com/kedacore/keda/issues/5261))
- **General**: Support profiling for KEDA components ([#4789](https://github.com/kedacore/keda/issues/4789))
- **CPU scaler**: Wait for metrics window during CPU scaler tests ([#5294](https://github.com/kedacore/keda/pull/5294))
Expand Down
1 change: 0 additions & 1 deletion apis/keda/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions controllers/keda/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
mock_scalers "github.com/kedacore/keda/v2/pkg/mock/mock_scaler"
"github.com/kedacore/keda/v2/pkg/mock/mock_scaling"
"github.com/kedacore/keda/v2/pkg/scalers"
"github.com/kedacore/keda/v2/pkg/scalers/scalersconfig"
"github.com/kedacore/keda/v2/pkg/scaling/cache"
)

Expand Down Expand Up @@ -133,8 +134,8 @@ func setupTest(health map[string]v1alpha1.HealthStatus, scaler *mock_scalers.Moc
scalersCache := cache.ScalersCache{
Scalers: []cache.ScalerBuilder{{
Scaler: scaler,
Factory: func() (scalers.Scaler, *scalers.ScalerConfig, error) {
return scaler, &scalers.ScalerConfig{}, nil
Factory: func() (scalers.Scaler, *scalersconfig.ScalerConfig, error) {
return scaler, &scalersconfig.ScalerConfig{}, nil
},
}},
Recorder: nil,
Expand Down
13 changes: 7 additions & 6 deletions controllers/keda/scaledobject_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/kedacore/keda/v2/pkg/mock/mock_client"
"github.com/kedacore/keda/v2/pkg/mock/mock_scaling"
"github.com/kedacore/keda/v2/pkg/scalers"
"github.com/kedacore/keda/v2/pkg/scalers/scalersconfig"
"github.com/kedacore/keda/v2/pkg/scaling/cache"
"github.com/kedacore/keda/v2/pkg/util"
)
Expand Down Expand Up @@ -81,7 +82,7 @@ var _ = Describe("ScaledObjectController", func() {
expectedExternalMetricNames := make([]string, 0)

for i, tm := range triggerMeta {
config := &scalers.ScalerConfig{
config := &scalersconfig.ScalerConfig{
ScalableObjectName: fmt.Sprintf("test.%d", i),
ScalableObjectNamespace: "test",
TriggerMetadata: tm,
Expand All @@ -97,7 +98,7 @@ var _ = Describe("ScaledObjectController", func() {

testScalers = append(testScalers, cache.ScalerBuilder{
Scaler: s,
Factory: func() (scalers.Scaler, *scalers.ScalerConfig, error) {
Factory: func() (scalers.Scaler, *scalersconfig.ScalerConfig, error) {
scaler, err := scalers.NewPrometheusScaler(config)
return scaler, config, err
},
Expand Down Expand Up @@ -133,7 +134,7 @@ var _ = Describe("ScaledObjectController", func() {
// Generate test data
expectedExternalMetricNames := make([]string, 0)

config := &scalers.ScalerConfig{
config := &scalersconfig.ScalerConfig{
ScalableObjectName: "test",
ScalableObjectNamespace: "test",
TriggerMetadata: triggerMeta[0],
Expand All @@ -154,7 +155,7 @@ var _ = Describe("ScaledObjectController", func() {
scalersCache := cache.ScalersCache{
Scalers: []cache.ScalerBuilder{{
Scaler: s,
Factory: func() (scalers.Scaler, *scalers.ScalerConfig, error) {
Factory: func() (scalers.Scaler, *scalersconfig.ScalerConfig, error) {
return s, config, nil
},
}},
Expand Down Expand Up @@ -183,7 +184,7 @@ var _ = Describe("ScaledObjectController", func() {
// Generate test data
testScalers := make([]cache.ScalerBuilder, 0)
for i := 0; i < 4; i++ {
config := &scalers.ScalerConfig{
config := &scalersconfig.ScalerConfig{
ScalableObjectName: fmt.Sprintf("test.%d", i),
ScalableObjectNamespace: "test",
TriggerMetadata: triggerMeta[0],
Expand All @@ -198,7 +199,7 @@ var _ = Describe("ScaledObjectController", func() {

testScalers = append(testScalers, cache.ScalerBuilder{
Scaler: s,
Factory: func() (scalers.Scaler, *scalers.ScalerConfig, error) {
Factory: func() (scalers.Scaler, *scalersconfig.ScalerConfig, error) {
return s, config, nil
},
})
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/Huawei/gophercloud v1.0.21
github.com/IBM/sarama v1.42.1
github.com/arangodb/go-driver v1.6.1
github.com/aws/aws-sdk-go-v2 v1.24.0
github.com/aws/aws-sdk-go-v2 v1.24.1
github.com/aws/aws-sdk-go-v2/config v1.26.2
github.com/aws/aws-sdk-go-v2/credentials v1.16.13
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.32.1
Expand Down Expand Up @@ -175,8 +175,8 @@ require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.10 // indirect
Expand Down
Loading
Loading