Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 771601a

Browse files
togashidmkillianmuldoon
authored andcommitted
Export CustomMetricsClient and NodeSorableMetric
- Exported func NewClient returns unexported type metrics. customMetricsClient. - Exported func OrderedList returns unexported type []core.nodeSort ableMetric. Then, NodeSorableMetric type exported. - Comment type change accordingly.
1 parent 85a21a1 commit 771601a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

pkg/metrics/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Provides instruments to read and cache Node Metrics from the custom metrics API.
1+
//Package metrics instruments to read and cache Node Metrics from the custom metrics API.
22
package metrics
33

44
import (
@@ -31,24 +31,24 @@ type NodeMetric struct {
3131
//NodeMetricsInfo holds a map of metric information related to a single named metric. The key for the map is the name of the node.
3232
type NodeMetricsInfo map[string]NodeMetric
3333

34-
//customMetrics client embeds a client for the custom Metrics API
35-
type customMetricsClient struct {
34+
//CustomMetricsClient embeds a client for the custom Metrics API
35+
type CustomMetricsClient struct {
3636
customclient.CustomMetricsClient
3737
}
3838

3939
//NewClient creates a new Metrics Client including discovering and mapping the available APIs, and pulling the API version.
40-
func NewClient(config *restclient.Config) customMetricsClient {
40+
func NewClient(config *restclient.Config) CustomMetricsClient {
4141
discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(config)
4242
cachedDiscoveryClient := cacheddiscovery.NewMemCacheClient(discoveryClient)
4343
restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedDiscoveryClient)
4444
restMapper.Reset()
4545
apiVersionsGetter := customclient.NewAvailableAPIsGetter(discoveryClient)
46-
metricsClient := customMetricsClient{customclient.NewForConfig(config, restMapper, apiVersionsGetter)}
46+
metricsClient := CustomMetricsClient{customclient.NewForConfig(config, restMapper, apiVersionsGetter)}
4747
return metricsClient
4848
}
4949

5050
//GetNodeMetric gets the given metric, time Window for Metric and timestamp for each node in the cluster.
51-
func (c customMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error) {
51+
func (c CustomMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error) {
5252
metrics, err := c.RootScopedMetrics().GetForObjects(schema.GroupKind{Kind: "Node"}, labels.NewSelector(), metricName, labels.NewSelector())
5353
if err != nil {
5454
return nil, errors.New("unable to fetch metrics from custom metrics API: " + err.Error())

pkg/strategies/core/operator.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func EvaluateRule(value resource.Quantity, rule telempol.TASPolicyRule) bool {
2323
}
2424
return operators[rule.Operator](value, rule.Target)
2525
}
26-
26+
//OrderedList will return a list of nodes ordered by their linked metric and operator
2727
//TODO: Make this method more generic so it can use objects other than nodes.
28-
func OrderedList(metricsInfo metrics.NodeMetricsInfo, operator string) []nodeSortableMetric {
29-
mtrcs := []nodeSortableMetric{}
28+
func OrderedList(metricsInfo metrics.NodeMetricsInfo, operator string) []NodeSortableMetric {
29+
mtrcs := []NodeSortableMetric{}
3030
for name, info := range metricsInfo {
31-
mtrcs = append(mtrcs, nodeSortableMetric{name, info.Value})
31+
mtrcs = append(mtrcs, NodeSortableMetric{name, info.Value})
3232
}
3333
switch operator {
3434
case "GreaterThan":
@@ -39,9 +39,9 @@ func OrderedList(metricsInfo metrics.NodeMetricsInfo, operator string) []nodeSor
3939
return mtrcs
4040
}
4141

42-
//This type is necessary in order to call the sort.Slice method.
42+
//NodeSortableMetric type is necessary in order to call the sort.Slice method.
4343
//Note lack of usage of time windows or stamps.
44-
type nodeSortableMetric struct {
44+
type NodeSortableMetric struct {
4545
NodeName string
4646
MetricValue resource.Quantity
4747
}

0 commit comments

Comments
 (0)