Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
  • Loading branch information
JorTurFer committed Apr 28, 2023
1 parent 4a4fb76 commit ec17d0c
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 64 deletions.
10 changes: 5 additions & 5 deletions pkg/apiserver/installer/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ type fakeCMProvider struct {
metrics []provider.CustomMetricInfo
}

func (p *fakeCMProvider) valuesFor(name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (string, []custom_metrics.MetricValue, bool) {
func (p *fakeCMProvider) valuesFor(name types.NamespacedName, info provider.CustomMetricInfo) (string, []custom_metrics.MetricValue, bool) {
if info.Namespaced {
metricID := name.Namespace + "/" + info.GroupResource.String() + "/" + name.Name + "/" + info.Metric
values, ok := p.namespacedValues[metricID]
Expand All @@ -193,17 +193,17 @@ func (p *fakeCMProvider) valuesFor(name types.NamespacedName, info provider.Cust
return metricID, values, ok
}

func (p *fakeCMProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error) {
metricID, values, ok := p.valuesFor(name, info, metricSelector)
func (p *fakeCMProvider) GetMetricByName(_ context.Context, name types.NamespacedName, info provider.CustomMetricInfo, _ labels.Selector) (*custom_metrics.MetricValue, error) {
metricID, values, ok := p.valuesFor(name, info)
if !ok {
return nil, fmt.Errorf("non-existent metric requested (id: %s)", metricID)
}

return &values[0], nil
}

func (p *fakeCMProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error) {
metricID, values, ok := p.valuesFor(types.NamespacedName{Namespace: namespace, Name: "*"}, info, metricSelector)
func (p *fakeCMProvider) GetMetricBySelector(_ context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, _ labels.Selector) (*custom_metrics.MetricValueList, error) {
metricID, values, ok := p.valuesFor(types.NamespacedName{Namespace: namespace, Name: "*"}, info)
if !ok {
return nil, fmt.Errorf("non-existent metric requested (id: %s)", metricID)
}
Expand Down
12 changes: 2 additions & 10 deletions pkg/apiserver/installer/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@ func ConvertURLValuesToV1beta2MetricListOptions(in *url.Values, out *cmv1beta2.M

// RegisterConversions adds conversion functions to the given scheme.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddConversionFunc((*url.Values)(nil), (*cmv1beta1.MetricListOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
return s.AddConversionFunc((*url.Values)(nil), (*cmv1beta1.MetricListOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
return ConvertURLValuesToV1beta1MetricListOptions(a.(*url.Values), b.(*cmv1beta1.MetricListOptions), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*url.Values)(nil), (*cmv1beta2.MetricListOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
return ConvertURLValuesToV1beta2MetricListOptions(a.(*url.Values), b.(*cmv1beta2.MetricListOptions), scope)
}); err != nil {
return err
}
return nil
})
}
Loading

0 comments on commit ec17d0c

Please sign in to comment.