Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#34 from astefanutti/pr-1.12.0
Browse files Browse the repository at this point in the history
Upgrade to Kubernetes 1.12
  • Loading branch information
k8s-ci-robot authored Nov 26, 2018
2 parents 21a51aa + d44330b commit bb8bae1
Show file tree
Hide file tree
Showing 3,441 changed files with 435,875 additions and 22,182 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
71 changes: 57 additions & 14 deletions glide.lock

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

8 changes: 4 additions & 4 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import:
- pkg/util/errors
- pkg/util/wait
- pkg/version
version: release-1.11
version: release-1.12

- package: k8s.io/apiserver
subpackages:
Expand All @@ -44,7 +44,7 @@ import:
- pkg/server
- pkg/server/options
- pkg/util/logs
version: release-1.11
version: release-1.12

- package: k8s.io/client-go
subpackages:
Expand All @@ -57,15 +57,15 @@ import:
- rest
- testing
- tools/clientcmd
version: release-8.0
version: release-9.0

- package: k8s.io/metrics
subpackages:
- pkg/apis/custom_metrics
- pkg/apis/custom_metrics/install
- pkg/apis/external_metrics
- pkg/apis/external_metrics/install
version: release-1.11
version: release-1.12

testImport:
- package: github.com/stretchr/testify
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type CustomMetricsAdapterServerOptions struct {

func NewCustomMetricsAdapterServerOptions() *CustomMetricsAdapterServerOptions {
o := &CustomMetricsAdapterServerOptions{
SecureServing: genericoptions.WithLoopback(genericoptions.NewSecureServingOptions()),
SecureServing: genericoptions.NewSecureServingOptions().WithLoopback(),
Authentication: genericoptions.NewDelegatingAuthenticationOptions(),
Authorization: genericoptions.NewDelegatingAuthorizationOptions(),
Features: genericoptions.NewFeatureOptions(),
Expand All @@ -59,11 +59,11 @@ func (o CustomMetricsAdapterServerOptions) Config() (*apiserver.Config, error) {
}

serverConfig := genericapiserver.NewConfig(apiserver.Codecs)
if err := o.SecureServing.ApplyTo(serverConfig); err != nil {
if err := o.SecureServing.ApplyTo(&serverConfig.SecureServing, &serverConfig.LoopbackClientConfig); err != nil {
return nil, err
}

if err := o.Authentication.ApplyTo(&serverConfig.Authentication, serverConfig.SecureServing, nil); err != nil {
if err := o.Authentication.ApplyTo(&serverConfig.Authentication, serverConfig.SecureServing, serverConfig.OpenAPIConfig); err != nil {
return nil, err
}
if err := o.Authorization.ApplyTo(&serverConfig.Authorization); err != nil {
Expand Down
28 changes: 20 additions & 8 deletions test-adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,30 @@ func (p *testingProvider) valueFor(info provider.CustomMetricInfo, name types.Na
}

// metricFor is a helper function which formats a value, metric, and object info into a MetricValue which can be returned by the metrics API
func (p *testingProvider) metricFor(value resource.Quantity, name types.NamespacedName, info provider.CustomMetricInfo) (*custom_metrics.MetricValue, error) {
func (p *testingProvider) metricFor(value resource.Quantity, name types.NamespacedName, selector labels.Selector, info provider.CustomMetricInfo) (*custom_metrics.MetricValue, error) {
objRef, err := helpers.ReferenceFor(p.mapper, name, info)
if err != nil {
return nil, err
}

return &custom_metrics.MetricValue{
metric := &custom_metrics.MetricValue{
DescribedObject: objRef,
MetricName: info.Metric,
Timestamp: metav1.Time{time.Now()},
Value: value,
}, nil
Metric: custom_metrics.MetricIdentifier{
Name: info.Metric,
},
Timestamp: metav1.Time{time.Now()},
Value: value,
}

if len(selector.String()) > 0 {
labelSelector, err := metav1.ParseToLabelSelector(selector.String())
if err != nil {
return nil, err
}
metric.Metric.Selector = labelSelector
}

return metric, nil
}

// metricsFor is a wrapper used by GetMetricBySelector to format several metrics which match a resource selector
Expand All @@ -237,7 +249,7 @@ func (p *testingProvider) metricsFor(namespace string, selector labels.Selector,
return nil, err
}

metric, err := p.metricFor(value, namespacedName, info)
metric, err := p.metricFor(value, namespacedName, selector, info)
if err != nil {
return nil, err
}
Expand All @@ -257,7 +269,7 @@ func (p *testingProvider) GetMetricByName(name types.NamespacedName, info provid
if err != nil {
return nil, err
}
return p.metricFor(value, name, info)
return p.metricFor(value, name, labels.Everything(), info)
}

func (p *testingProvider) GetMetricBySelector(namespace string, selector labels.Selector, info provider.CustomMetricInfo) (*custom_metrics.MetricValueList, error) {
Expand Down
Loading

0 comments on commit bb8bae1

Please sign in to comment.