Skip to content

Commit

Permalink
fix typos and update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
JorTurFer committed Apr 26, 2023
1 parent c950c89 commit 5e5c464
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 3 additions & 4 deletions pkg/apiserver/installer/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
emv1beta1 "k8s.io/metrics/pkg/apis/external_metrics/v1beta1"

"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider/defaults"
custommetricstorage "sigs.k8s.io/custom-metrics-apiserver/pkg/registry/custom_metrics"
externalmetricstorage "sigs.k8s.io/custom-metrics-apiserver/pkg/registry/external_metrics"
sampleprovider "sigs.k8s.io/custom-metrics-apiserver/test-adapter/provider"
Expand Down Expand Up @@ -180,6 +181,8 @@ type fakeCMProvider struct {
rootSubsetCounts map[string]int
namespacedSubsetCounts map[string]int
metrics []provider.CustomMetricInfo

defaults.DefaultCustomMetricsProvider
}

func (p *fakeCMProvider) valuesFor(name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (string, []custom_metrics.MetricValue, bool) {
Expand Down Expand Up @@ -241,10 +244,6 @@ func (p *fakeCMProvider) GetMetricBySelector(ctx context.Context, namespace stri
return &trimmedValues, nil
}

func (p *fakeCMProvider) ListAllMetrics() []provider.CustomMetricInfo {
return p.metrics
}

type T struct {
Method string
Path string
Expand Down
14 changes: 5 additions & 9 deletions pkg/provider/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ import (
"k8s.io/metrics/pkg/apis/external_metrics"

"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider/defaults"
)

type fakeProvider struct{}
type fakeProvider struct {
defaults.DefaultCustomMetricsProvider
defaults.DefaultExternalMetricsProvider
}

func (*fakeProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error) {
return &custom_metrics.MetricValue{}, nil
Expand All @@ -38,18 +42,10 @@ func (*fakeProvider) GetMetricBySelector(ctx context.Context, namespace string,
return &custom_metrics.MetricValueList{}, nil
}

func (*fakeProvider) ListAllMetrics() []provider.CustomMetricInfo {
return []provider.CustomMetricInfo{}
}

func (*fakeProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
return &external_metrics.ExternalMetricValueList{}, nil
}

func (*fakeProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo {
return []provider.ExternalMetricInfo{}
}

// NewProvider creates a fake implementation of MetricsProvider.
func NewProvider() provider.MetricsProvider {
return &fakeProvider{}
Expand Down

0 comments on commit 5e5c464

Please sign in to comment.