about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-11-25T16·35+0100
committerFlorian Klink <flokli@flokli.de>2019-11-25T16·35+0100
commit40b2f11543ac78a68d01d4046fc4507da21f1ec9 (patch)
tree54975ac41af49a6f7124bf9cd48699d2dd8245fb
parentfecbf8b3e2efd4ba8c2e33159269000db2fbe1da (diff)
frontend: only pass runner to MakeFrontend, add Runner.GetSubmitQueue()
-rw-r--r--frontend/frontend.go4
-rw-r--r--main.go2
-rw-r--r--submitqueue/runner.go5
3 files changed, 9 insertions, 2 deletions
diff --git a/frontend/frontend.go b/frontend/frontend.go
index 0718bb136d1f..77a792f6440e 100644
--- a/frontend/frontend.go
+++ b/frontend/frontend.go
@@ -42,9 +42,11 @@ func loadTemplate(templateName string, funcMap template.FuncMap) (*template.Temp
 }
 
 // MakeFrontend configures the router and returns a new Frontend struct
-func MakeFrontend(runner *submitqueue.Runner, submitQueue *submitqueue.SubmitQueue) *Frontend {
+func MakeFrontend(runner *submitqueue.Runner) *Frontend {
 	router := gin.Default()
 
+	submitQueue := runner.GetSubmitQueue()
+
 	funcMap := template.FuncMap{
 		"isAutoSubmittable": func(serie *submitqueue.Serie) bool {
 			return submitQueue.IsAutoSubmittable(serie)
diff --git a/main.go b/main.go
index de56d9072c82..14320276377f 100644
--- a/main.go
+++ b/main.go
@@ -91,7 +91,7 @@ func main() {
 		submitQueue := submitqueue.MakeSubmitQueue(gerritClient, projectName, branchName, submitQueueTag)
 		runner := submitqueue.NewRunner(submitQueue)
 
-		handler := frontend.MakeFrontend(runner, submitQueue)
+		handler := frontend.MakeFrontend(runner)
 
 		// fetch only on first run
 		runner.Trigger(true)
diff --git a/submitqueue/runner.go b/submitqueue/runner.go
index 2c84a7d69b7f..23ff46bea4b3 100644
--- a/submitqueue/runner.go
+++ b/submitqueue/runner.go
@@ -28,6 +28,11 @@ func (r *Runner) GetResults() (*time.Time, []*Result) {
 	return r.currentlyRunning, r.results
 }
 
+// GetSubmitQueue returns the submit queue object, to be consumed by the frontend
+func (r *Runner) GetSubmitQueue() (*SubmitQueue) {
+	return r.SubmitQueue
+}
+
 // Trigger starts a new batch job
 // TODO: make sure only one batch job is started at the same time
 // if a batch job is already started, ignore the newest request