Skip to content

Commit

Permalink
Add String() implementation for MetricInfo
Browse files Browse the repository at this point in the history
This commit adds an implementation of `String()` for
provider.MetricInfo, which should make printing errors and debug
messages easier.
  • Loading branch information
DirectXMan12 committed Jun 6, 2017
1 parent 0d451f3 commit daee026
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/provider/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package provider

import (
"fmt"

"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/metrics/pkg/apis/custom_metrics"
Expand All @@ -25,9 +27,17 @@ import (
// MetricInfo describes a metric for a particular
// fully-qualified group resource.
type MetricInfo struct {
GroupResource schema.GroupResource
Namespaced bool
Metric string
GroupResource schema.GroupResource
Namespaced bool
Metric string
}

func (i MetricInfo) String() string {
if i.Namespaced {
return fmt.Sprintf("%s/%s(namespaced)", i.GroupResource.String(), i.Metric)
} else {
return fmt.Sprintf("%s/%s", i.GroupResource.String(), i.Metric)
}
}

// CustomMetricsProvider is a soruce of custom metrics
Expand Down

0 comments on commit daee026

Please sign in to comment.