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

Commit 7aa8cfc

Browse files
killianmuldoontogashidm
authored andcommitted
Reformat code with gofmt
There were a number of go format violations in the project. This change results in a properly formatted go project.
1 parent 1401741 commit 7aa8cfc

File tree

18 files changed

+37
-34
lines changed

18 files changed

+37
-34
lines changed

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"github.com/intel/telemetry-aware-scheduling/pkg/controller"
66
"github.com/intel/telemetry-aware-scheduling/pkg/metrics"
77
"github.com/intel/telemetry-aware-scheduling/pkg/scheduler"
8-
"github.com/intel/telemetry-aware-scheduling/pkg/telemetryscheduler"
98
strategy "github.com/intel/telemetry-aware-scheduling/pkg/strategies/core"
109
"github.com/intel/telemetry-aware-scheduling/pkg/strategies/deschedule"
1110
"github.com/intel/telemetry-aware-scheduling/pkg/strategies/dontschedule"
1211
"github.com/intel/telemetry-aware-scheduling/pkg/strategies/scheduleonmetric"
1312
telemetrypolicyclient "github.com/intel/telemetry-aware-scheduling/pkg/telemetrypolicy/client/v1alpha1"
13+
"github.com/intel/telemetry-aware-scheduling/pkg/telemetryscheduler"
1414
"k8s.io/client-go/kubernetes"
1515
"k8s.io/client-go/rest"
1616
"k8s.io/client-go/tools/clientcmd"
@@ -36,7 +36,7 @@ func main() {
3636
flag.StringVar(&syncPeriod, "syncPeriod", "5s", "length of time in seconds between metrics updates")
3737
flag.Parse()
3838
cache := tascache.NewAutoUpdatingCache()
39-
tscheduler := telemetryscheduler.NewMetricsExtender(cache)
39+
tscheduler := telemetryscheduler.NewMetricsExtender(cache)
4040
sch := scheduler.Server{ExtenderScheduler: tscheduler}
4141
go sch.StartServer(port, certFile, keyFile, caFile, unsafe)
4242
tasController(kubeConfig, syncPeriod, cache)

pkg/cache/autoupdating.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (n *AutoUpdatingCache) ReadPolicy(namespace string, policyName string) (tel
9292
}
9393
return telemetrypolicy.TASPolicy{}, errors.New("no policy of this name found")
9494
}
95+
9596
//WritePolicy sends the passed object to be stored in the cache under the namespace/name
9697
func (n *AutoUpdatingCache) WritePolicy(namespace string, policyName string, policy telemetrypolicy.TASPolicy) error {
9798
n.add(fmt.Sprintf(policyPath, namespace, policyName), policy)

pkg/cache/autoupdating_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestNodeMetricsCache_ReadMetric(t *testing.T) {
8686
return
8787
}
8888
if !reflect.DeepEqual(got, tt.want) {
89-
t.Errorf("AutoUpdatingCache.ReadMetric() = %v, deleted %v", got, tt.want)
89+
t.Errorf("AutoUpdatingCache.ReadMetric() = %v, deleted %v", got, tt.want)
9090
}
9191
})
9292
}
@@ -117,7 +117,7 @@ func TestNodeMetricsCache_ReadPolicy(t *testing.T) {
117117
return
118118
}
119119
if !reflect.DeepEqual(got, tt.want) {
120-
t.Errorf("AutoUpdatingCache.ReadPolicy() = %v, deleted %v", got, tt.want)
120+
t.Errorf("AutoUpdatingCache.ReadPolicy() = %v, deleted %v", got, tt.want)
121121
}
122122
if tt.wantErr {
123123
t.Errorf("no error fired")

pkg/cache/cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (c concurrentCache) newRequest(t requestType) request {
3838
return request{Type: t}
3939
}
4040
}
41+
4142
//run runs a constant goroutine waiting for requests and setting up the initial data structure.
4243
func (c concurrentCache) run(ch chan request, initialData map[string]interface{}) {
4344
cache := initialData
@@ -60,6 +61,7 @@ func (c concurrentCache) run(ch chan request, initialData map[string]interface{}
6061
}
6162
}
6263
}
64+
6365
//Send to channel is a helper method that sends the request to the passed channel.
6466
func sendToChannel(ch chan request, req request) {
6567
ch <- req
@@ -81,6 +83,7 @@ func (c concurrentCache) delete(key string) {
8183
r.Key = key
8284
sendToChannel(c.cache, r)
8385
}
86+
8487
//Read creates a read request and sends it into the cache channel.
8588
func (c concurrentCache) read(itemName string) interface{} {
8689
r := c.newRequest(READ)

pkg/cache/mocks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package cache
2+
23
//This file contains mock methods and objects which are used to test across the TAS packages.
34
import (
45
"github.com/intel/telemetry-aware-scheduling/pkg/metrics"

pkg/controller/controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (controller *TelemetryPolicyController) Run(context context.Context) {
2525
}
2626
<-context.Done()
2727
}
28+
2829
//Watch sets up the watcher on the kubernetes api server and adds event handlers for add, update and delete.
2930
func (controller *TelemetryPolicyController) watch(context context.Context) (cache.Controller, error) {
3031
source := cache.NewListWatchFromClient(
@@ -47,7 +48,6 @@ func (controller *TelemetryPolicyController) watch(context context.Context) (cac
4748
return policyController, nil
4849
}
4950

50-
5151
//onAdd fires when the controller sees a new policy in the apiserver. It adds the policy to the cache and adds each of its metrics to the cache.
5252
// It also adds the strategies contained in the policy to the strategy enforcer.
5353
func (controller *TelemetryPolicyController) onAdd(obj interface{}) {
@@ -119,7 +119,7 @@ func (controller *TelemetryPolicyController) onUpdate(old, new interface{}) {
119119
controller.Enforcer.RemoveStrategy(oldStrat, oldStrat.StrategyType())
120120
for _, rule := range oldPol.Spec.Strategies[oldStrat.StrategyType()].Rules {
121121
err := controller.DeleteMetric(rule.Metricname)
122-
if err != nil{
122+
if err != nil {
123123
log.Print(err)
124124
}
125125
}
@@ -153,12 +153,12 @@ func (controller *TelemetryPolicyController) onDelete(obj interface{}) {
153153
controller.Enforcer.RemoveStrategy(strt, strt.StrategyType())
154154
for _, rule := range polCopy.Spec.Strategies[strt.StrategyType()].Rules {
155155
err := controller.DeleteMetric(rule.Metricname)
156-
if err != nil{
156+
if err != nil {
157157
log.Print(err)
158158
}
159159
}
160160
}
161-
err:= controller.DeletePolicy(polCopy.Namespace, polCopy.Name)
161+
err := controller.DeletePolicy(polCopy.Namespace, polCopy.Name)
162162
if err != nil {
163163
log.Print(err)
164164
return

pkg/controller/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ func TestTelemetryPolicyController_Run(t *testing.T) {
4646
})
4747
mockServer.Close()
4848
}
49-
}
49+
}

pkg/scheduler/scheduler.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ will not run.
6565
//handlerWithMiddleware is handler wrapped with middleware to serve the prechecks at endpoint
6666
func handlerWithMiddleware(handle http.HandlerFunc) http.HandlerFunc {
6767
return requestContentType(
68-
contentLength(
69-
postOnly(handle),
70-
),
71-
)
68+
contentLength(
69+
postOnly(handle),
70+
),
71+
)
7272
}
7373

7474
//error handler deals with requests sent to an invalid endpoint and returns a 404.
@@ -93,7 +93,7 @@ func checkSymLinks(filename string) error {
9393
// StartServer starts the HTTP server needed for scheduler.
9494
// It registers the handlers and checks for existing telemetry policies.
9595
func (m Server) StartServer(port string, certFile string, keyFile string, caFile string, unsafe bool) {
96-
mx:= http.NewServeMux()
96+
mx := http.NewServeMux()
9797
mx.HandleFunc("/", handlerWithMiddleware(errorHandler))
9898
mx.HandleFunc("/scheduler/prioritize", handlerWithMiddleware(m.Prioritize))
9999
mx.HandleFunc("/scheduler/filter", handlerWithMiddleware(m.Filter))
@@ -132,13 +132,13 @@ func configureSecureServer(port string, caFile string) *http.Server {
132132
caCertPool.AppendCertsFromPEM(caCert)
133133

134134
cfg := &tls.Config{
135-
MinVersion: tls.VersionTLS12,
136-
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
137-
ClientCAs: caCertPool,
138-
ClientAuth: tls.RequireAndVerifyClientCert,
139-
PreferServerCipherSuites: true,
140-
InsecureSkipVerify: false,
141-
CipherSuites: []uint16{
135+
MinVersion: tls.VersionTLS12,
136+
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
137+
ClientCAs: caCertPool,
138+
ClientAuth: tls.RequireAndVerifyClientCert,
139+
PreferServerCipherSuites: true,
140+
InsecureSkipVerify: false,
141+
CipherSuites: []uint16{
142142
// tls 1.2
143143
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
144144
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,

pkg/strategies/core/enforcer_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,3 @@ func TestMetricEnforcer_RemoveStrategy(t *testing.T) {
288288
})
289289
}
290290
}
291-

pkg/strategies/core/mocks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ func (v *MockStrategy) GetPolicyName() string {
3535
}
3636

3737
//SetPolicyName sets the policy name of the mock strategy
38-
func (v *MockStrategy) SetPolicyName( policyName string) {
38+
func (v *MockStrategy) SetPolicyName(policyName string) {
3939

40-
}
40+
}

0 commit comments

Comments
 (0)