Skip to content

Commit 44b998c

Browse files
committed
Renamings
1 parent 2db6008 commit 44b998c

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

cmd/autoscaler/app/autoscaler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/v3io/scaler/pkg/autoscaler"
28-
"github.com/v3io/scaler/pkg/autoscaler/factory"
28+
"github.com/v3io/scaler/pkg/autoscaler/metricsclient"
2929
"github.com/v3io/scaler/pkg/common"
3030
"github.com/v3io/scaler/pkg/pluginloader"
3131
"github.com/v3io/scaler/pkg/scalertypes"
@@ -48,7 +48,7 @@ func Run(kubeconfigPath string,
4848
Kind: metricsResourceKind,
4949
Group: metricsResourceGroup,
5050
},
51-
MetricClientOptions: scalertypes.MetricClientOptions{
51+
MetricsClientOptions: scalertypes.MetricsClientOptions{
5252
Kind: scalertypes.KindCustomMetrics,
5353
},
5454
}
@@ -104,7 +104,7 @@ func createAutoScaler(restConfig *rest.Config,
104104
}
105105

106106
// create metrics client using factory
107-
metricsClient, err := factory.NewMetricsClient(rootLogger, restConfig, options)
107+
metricsClient, err := metricsclient.NewMetricsClient(rootLogger, restConfig, options)
108108
if err != nil {
109109
return nil, errors.Wrap(err, "Failed to create metrics client")
110110
}

pkg/autoscaler/metricsclients/custommetricswrapper.go renamed to pkg/autoscaler/metricsclient/custommetrics.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ under the Apache 2.0 license is conditioned upon your compliance with
1818
such restriction.
1919
*/
2020

21-
package metricsclients
21+
package metricsclient
2222

2323
import (
2424
"github.com/nuclio/errors"
@@ -30,42 +30,42 @@ import (
3030
"k8s.io/client-go/discovery/cached/memory"
3131
"k8s.io/client-go/rest"
3232
"k8s.io/client-go/restmapper"
33-
"k8s.io/metrics/pkg/client/custom_metrics"
33+
k8scustommetrics "k8s.io/metrics/pkg/client/custom_metrics"
3434
)
3535

36-
type CustomMetricsWrapper struct {
37-
custom_metrics.CustomMetricsClient
36+
type CustomMetricsClient struct {
37+
k8scustommetrics.CustomMetricsClient
3838
namespace string
3939
groupKind schema.GroupKind
4040
logger logger.Logger
4141
}
4242

4343
// NewCustomMetricsClientFromConfig creates a custom_metrics.CustomMetricsClient from rest.Config
44-
func NewCustomMetricsClientFromConfig(restConfig *rest.Config) (custom_metrics.CustomMetricsClient, error) {
44+
func NewCustomMetricsClientFromConfig(restConfig *rest.Config) (k8scustommetrics.CustomMetricsClient, error) {
4545
discoveryClient, err := discovery.NewDiscoveryClientForConfig(restConfig)
4646
if err != nil {
4747
return nil, errors.Wrap(err, "Failed to create discovery client")
4848
}
49-
availableAPIsGetter := custom_metrics.NewAvailableAPIsGetter(discoveryClient)
49+
availableAPIsGetter := k8scustommetrics.NewAvailableAPIsGetter(discoveryClient)
5050
restMapper := restmapper.NewDeferredDiscoveryRESTMapper(memory.NewMemCacheClient(discoveryClient))
51-
customMetricsClient := custom_metrics.NewForConfig(restConfig, restMapper, availableAPIsGetter)
51+
customMetricsClient := k8scustommetrics.NewForConfig(restConfig, restMapper, availableAPIsGetter)
5252
return customMetricsClient, nil
5353
}
5454

55-
func NewCustomMetricsWrapper(
55+
func NewCustomMetricsClient(
5656
logger logger.Logger,
57-
customMetricsClient custom_metrics.CustomMetricsClient,
57+
customMetricsClient k8scustommetrics.CustomMetricsClient,
5858
namespace string,
59-
groupKind schema.GroupKind) *CustomMetricsWrapper {
60-
return &CustomMetricsWrapper{
59+
groupKind schema.GroupKind) *CustomMetricsClient {
60+
return &CustomMetricsClient{
6161
logger: logger,
6262
CustomMetricsClient: customMetricsClient,
6363
namespace: namespace,
6464
groupKind: groupKind,
6565
}
6666
}
6767

68-
func (cmw *CustomMetricsWrapper) GetResourceMetrics(metricNames []string) (map[string]map[string]int, error) {
68+
func (cmw *CustomMetricsClient) GetResourceMetrics(metricNames []string) (map[string]map[string]int, error) {
6969
resourcesMetricsMap := make(map[string]map[string]int)
7070
resourceLabels := labels.Everything()
7171
metricSelectorLabels := labels.Everything()
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,33 @@ under the Apache 2.0 license is conditioned upon your compliance with
1818
such restriction.
1919
*/
2020

21-
package factory
21+
package metricsclient
2222

2323
import (
2424
"fmt"
2525

26-
"github.com/v3io/scaler/pkg/autoscaler/metricsclients"
2726
"github.com/v3io/scaler/pkg/scalertypes"
2827

2928
"github.com/nuclio/errors"
3029
"github.com/nuclio/logger"
3130
"k8s.io/client-go/rest"
3231
)
3332

34-
func NewMetricsClient(logger logger.Logger, restConfig *rest.Config, autoScalerConf scalertypes.AutoScalerOptions) (scalertypes.MetricsClient, error) {
35-
switch autoScalerConf.MetricClientOptions.Kind {
33+
func NewMetricsClient(logger logger.Logger,
34+
restConfig *rest.Config,
35+
autoScalerConf scalertypes.AutoScalerOptions) (scalertypes.MetricsClient, error) {
36+
switch autoScalerConf.MetricsClientOptions.Kind {
3637
case scalertypes.KindCustomMetrics:
37-
customMetricsClient, err := metricsclients.NewCustomMetricsClientFromConfig(restConfig)
38+
customMetricsClient, err := NewCustomMetricsClientFromConfig(restConfig)
3839
if err != nil {
3940
return nil, errors.Wrap(err, "Failed to create custom metrics client")
4041
}
41-
return metricsclients.NewCustomMetricsWrapper(
42+
return NewCustomMetricsClient(
4243
logger.GetChild("customMetricsClient"),
4344
customMetricsClient,
4445
autoScalerConf.Namespace,
4546
autoScalerConf.GroupKind), nil
4647
default:
47-
return nil, fmt.Errorf("unsupported metrics client kind: %s", autoScalerConf.MetricClientOptions.Kind)
48+
return nil, fmt.Errorf("unsupported metrics client kind: %s", autoScalerConf.MetricsClientOptions.Kind)
4849
}
4950
}

pkg/scalertypes/types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ const (
3939
KindCustomMetrics = "customMetrics"
4040
)
4141

42-
type MetricClientOptions struct {
42+
type MetricsClientOptions struct {
4343
Kind Kind
4444
URL string
4545
Template string
4646
}
4747

4848
type AutoScalerOptions struct {
49-
Namespace string
50-
ScaleInterval Duration
51-
GroupKind schema.GroupKind
52-
MetricClientOptions MetricClientOptions
49+
Namespace string
50+
ScaleInterval Duration
51+
GroupKind schema.GroupKind
52+
MetricsClientOptions MetricsClientOptions
5353
}
5454

5555
type ResourceScalerConfig struct {

0 commit comments

Comments
 (0)