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

Commit 85a21a1

Browse files
togashidmkillianmuldoon
authored andcommitted
Fix comments and comment on exported elements
1 parent b123bfd commit 85a21a1

File tree

17 files changed

+67
-27
lines changed

17 files changed

+67
-27
lines changed

pkg/cache/autoupdating.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (n *AutoUpdatingCache) WriteMetric(metricName string, data metrics.NodeMetr
113113
return nil
114114
}
115115

116-
//Delete policy removes the policy removes the policy object at the given namespace/name string from the cache
116+
//DeletePolicy removes the policy removes the policy object at the given namespace/name string from the cache
117117
func (n *AutoUpdatingCache) DeletePolicy(namespace string, policyName string) error {
118118
log.Print("deleting", fmt.Sprintf(policyPath, namespace, policyName))
119119
n.delete(fmt.Sprintf(policyPath, namespace, policyName))

pkg/cache/cache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package cache
22

33
type requestType uint
44

5+
//const for requestType value
56
const (
67
READ requestType = iota
78
WRITE
89
DELETE
910
)
1011

12+
//Interface contains the baseline behaviour for a cache
1113
type Interface interface {
1214
add(string, interface{})
1315
delete(string)

pkg/cache/mocks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ import (
88
"time"
99
)
1010

11+
//MockEmptySelfUpdatingCache returns auto updating cache
1112
func MockEmptySelfUpdatingCache() ReaderWriter {
1213
n := NewAutoUpdatingCache()
1314
go n.PeriodicUpdate(*time.NewTicker(time.Second), metrics.NewDummyMetricsClient(map[string]metrics.NodeMetricsInfo{}), map[string]interface{}{})
1415
return n
1516
}
1617

18+
//MockSelfUpdatingCache returns auto updating cache
1719
func MockSelfUpdatingCache() *AutoUpdatingCache {
1820
n := MockEmptySelfUpdatingCache()
1921
_ = n.WriteMetric("dummyMetric1", TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}))
2022
_ = n.WriteMetric("dummyMetric2", TestNodeMetricCustomInfo([]string{"node 1", "node2"}, []int64{100, 200}))
2123
_ = n.WriteMetric("dummyMetric3", TestNodeMetricCustomInfo([]string{"node Z", "node Y"}, []int64{8, 40000000}))
2224
return n.(*AutoUpdatingCache)
2325
}
26+
27+
//TestNodeMetricCustomInfo returns the node metrics information
2428
func TestNodeMetricCustomInfo(nodeNames []string, numbers []int64) metrics.NodeMetricsInfo {
2529
n := metrics.NodeMetricsInfo{}
2630
for i, name := range nodeNames {

pkg/cache/remote.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"net/http"
99
)
1010

11+
//RemoteClient can send http requests to a single endpoint
1112
type RemoteClient struct {
1213
endpoint string
1314
http.Client
1415
}
1516

16-
//Register endpoint adds an endpoint for the metrics getter to read from
17+
//RegisterEndpoint adds an endpoint for the metrics getter to read from
1718
func (r *RemoteClient) RegisterEndpoint(endpoint string) {
1819
r.endpoint = endpoint
1920
}

pkg/cache/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ReaderWriter interface {
2626
Writer
2727
}
2828

29-
//TasCache describes functionality to periodically update all metrics in the metric cache.
29+
//SelfUpdating describes functionality to periodically update all metrics in the metric cache.
3030
type SelfUpdating interface {
3131
PeriodicUpdate(time.Ticker, metrics.Client, map[string]interface{})
3232
}

pkg/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Provides a controller that can be used to watch policies in the Kuebrnetes API.
1+
//Package controller provides a controller that can be used to watch policies in the Kubernetes API.
22
//It registers strategies from those policies to an enforcer.
33
package controller
44

pkg/metrics/mocks.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
1212
"time"
1313
)
14-
//Mocks used for testing in the metrics and other packages
14+
15+
//DummyRestClientConfig Mocks used for testing in the metrics and other packages
1516
func DummyRestClientConfig() *restclient.Config {
1617
tmpFile, err := ioutil.TempFile("", "cmdtests_temp")
1718
if err != nil {
@@ -28,22 +29,26 @@ func DummyRestClientConfig() *restclient.Config {
2829
return restConfig
2930
}
3031

32+
//DummyMetricsClient structured with a map of NodeMetricsInfo
3133
type DummyMetricsClient struct {
3234
store *map[string]NodeMetricsInfo
3335
}
3436

37+
//InstanceOfMockMetricClientMap refers to the metrics from Nodes
3538
var InstanceOfMockMetricClientMap = map[string]NodeMetricsInfo{
3639
"dummyMetric1": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
3740
"dummyMetric2": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
3841
"dummyMetric3": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
3942
}
4043

44+
//NewDummyMetricsClient receives the Node metrics and return the map values of client
4145
func NewDummyMetricsClient(cache map[string]NodeMetricsInfo) Client {
4246
return DummyMetricsClient{
4347
&cache,
4448
}
4549
}
4650

51+
//GetNodeMetric returns the NodeMetricsInfo of a metric when it exists.
4752
func (d DummyMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error) {
4853
s := *d.store
4954
if v, ok := s[metricName]; ok {
@@ -52,6 +57,7 @@ func (d DummyMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, e
5257
return nil, errors.New("metric not found")
5358
}
5459

60+
//TestNodeMetricCustomInfo returns slice with NodeMetrics from a arrays of nodesNames and numbers.
5561
func TestNodeMetricCustomInfo(nodeNames []string, numbers []int64) NodeMetricsInfo {
5662
n := NodeMetricsInfo{}
5763
for i, name := range nodeNames {

pkg/scheduler/scheduler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Logic for the scheduler extender - including the server it starts and prioritize + filter methods - is implemented in this package.
1+
//Package scheduler extender logic contains code to respond call from the http endpoint.
22
package scheduler
33

44
import (
@@ -22,12 +22,12 @@ import (
2222
"time"
2323
)
2424

25-
//Metrics Extender holds information on the cache holding scheduling strategies and metrics.
25+
//MetricsExtender holds information on the cache holding scheduling strategies and metrics.
2626
type MetricsExtender struct {
2727
cache cache.Reader
2828
}
2929

30-
//Returns a new metric Extender with the cache passed to it.
30+
//NewMetricsExtender returns a new metric Extender with the cache passed to it.
3131
func NewMetricsExtender(newCache cache.Reader) MetricsExtender {
3232
return MetricsExtender{
3333
cache: newCache,
@@ -274,7 +274,7 @@ func checkSymLinks(filename string) error {
274274
return nil
275275
}
276276

277-
// startHttpServer starts the HTTP server needed for scheduler.
277+
// StartServer starts the HTTP server needed for scheduler.
278278
// It registers the handlers and checks for existing telemetry policies.
279279
func (m MetricsExtender) StartServer(port string, certFile string, keyFile string, unsafe bool) {
280280
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { m.errorHandler(w, r) })

pkg/scheduler/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"net/http"
66
)
77

8-
//A scheduler extender has the capabilities needed to prioritize and filter nodes based on http requests.
9-
type SchedulerExtender interface {
8+
//ExtenderScheduler has the capabilities needed to prioritize and filter nodes based on http requests.
9+
type ExtenderScheduler interface {
1010
Prioritize(w http.ResponseWriter, r *http.Request)
1111
Filter(w http.ResponseWriter, r *http.Request)
1212
}

pkg/strategies/core/enforcer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (e *MetricEnforcer) RegisterStrategyType(str Interface) {
3030
e.RegisteredStrategies[str.StrategyType()] = map[Interface]interface{}{}
3131
}
3232

33+
//IsRegistered checks to see if a passed strategy is already being enforced
3334
func (e *MetricEnforcer) IsRegistered(str string) bool {
3435
e.Lock()
3536
defer e.Unlock()
@@ -57,6 +58,7 @@ func (e *MetricEnforcer) RegisteredStrategyTypes() []string {
5758
return output
5859
}
5960

61+
//RemoveStrategy will take a strategy out of the enforcer if it's currently registered
6062
func (e *MetricEnforcer) RemoveStrategy(str Interface, strategyType string) {
6163
e.Lock()
6264
defer e.Unlock()

0 commit comments

Comments
 (0)