1
1
package handlers
2
2
3
3
import (
4
- "github.com/gaia-pipeline/gaia/helper/stringhelper"
5
4
"net/http"
6
5
"strconv"
7
6
"time"
8
7
8
+ "github.com/gaia-pipeline/gaia/helper/stringhelper"
9
+
9
10
"github.com/gaia-pipeline/gaia/security"
10
11
11
12
"github.com/gaia-pipeline/gaia"
@@ -118,9 +119,9 @@ func PipelineGet(c echo.Context) error {
118
119
}
119
120
120
121
// Look up pipeline for the given id
121
- for _ , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
122
- if pipeline .ID == pipelineID {
123
- return c .JSON (http .StatusOK , pipeline )
122
+ for _ , p := range pipeline .GlobalActivePipelines .GetAll () {
123
+ if p .ID == pipelineID {
124
+ return c .JSON (http .StatusOK , p )
124
125
}
125
126
}
126
127
@@ -138,9 +139,9 @@ func PipelineUpdate(c echo.Context) error {
138
139
139
140
// Look up pipeline for the given id
140
141
var foundPipeline gaia.Pipeline
141
- for _ , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
142
- if pipeline .ID == p .ID {
143
- foundPipeline = pipeline
142
+ for _ , pipe := range pipeline .GlobalActivePipelines .GetAll () {
143
+ if pipe .ID == p .ID {
144
+ foundPipeline = pipe
144
145
break
145
146
}
146
147
}
@@ -184,8 +185,8 @@ func PipelineUpdate(c echo.Context) error {
184
185
foundPipeline .CronInst = cron .New ()
185
186
186
187
// Iterate over all cron schedules.
187
- for _ , cron := range p .PeriodicSchedules {
188
- err := foundPipeline .CronInst .AddFunc (cron , func () {
188
+ for _ , schedule := range p .PeriodicSchedules {
189
+ err := foundPipeline .CronInst .AddFunc (schedule , func () {
189
190
_ , err := schedulerService .SchedulePipeline (& foundPipeline , []* gaia.Argument {})
190
191
if err != nil {
191
192
gaia .Cfg .Logger .Error ("cannot schedule pipeline from periodic schedule" , "error" , err , "pipeline" , foundPipeline )
@@ -246,9 +247,9 @@ func PipelineDelete(c echo.Context) error {
246
247
// Look up pipeline for the given id
247
248
var foundPipeline gaia.Pipeline
248
249
var deletedPipelineIndex int
249
- for index , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
250
- if pipeline .ID == pipelineID {
251
- foundPipeline = pipeline
250
+ for index , p := range pipeline .GlobalActivePipelines .GetAll () {
251
+ if p .ID == pipelineID {
252
+ foundPipeline = p
252
253
deletedPipelineIndex = index
253
254
break
254
255
}
@@ -298,9 +299,9 @@ func PipelineTrigger(c echo.Context) error {
298
299
299
300
// Look up pipeline for the given id
300
301
var foundPipeline gaia.Pipeline
301
- for _ , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
302
- if pipeline .ID == pipelineID {
303
- foundPipeline = pipeline
302
+ for _ , p := range pipeline .GlobalActivePipelines .GetAll () {
303
+ if p .ID == pipelineID {
304
+ foundPipeline = p
304
305
break
305
306
}
306
307
}
@@ -314,8 +315,8 @@ func PipelineTrigger(c echo.Context) error {
314
315
}
315
316
316
317
schedulerService , _ := services .SchedulerService ()
317
- args := []* gaia.Argument {}
318
- c .Bind (& args )
318
+ var args []* gaia.Argument
319
+ _ = c .Bind (& args )
319
320
pipelineRun , err := schedulerService .SchedulePipeline (& foundPipeline , args )
320
321
if err != nil {
321
322
return c .String (http .StatusBadRequest , err .Error ())
@@ -340,9 +341,9 @@ func PipelineResetToken(c echo.Context) error {
340
341
341
342
// Look up pipeline for the given id
342
343
var foundPipeline gaia.Pipeline
343
- for _ , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
344
- if pipeline .ID == pipelineID {
345
- foundPipeline = pipeline
344
+ for _ , p := range pipeline .GlobalActivePipelines .GetAll () {
345
+ if p .ID == pipelineID {
346
+ foundPipeline = p
346
347
break
347
348
}
348
349
}
@@ -395,8 +396,8 @@ func PipelineStart(c echo.Context) error {
395
396
396
397
// Look for arguments.
397
398
// We do not check for errors here cause arguments are optional.
398
- args := []* gaia.Argument {}
399
- c .Bind (& args )
399
+ var args []* gaia.Argument
400
+ _ = c .Bind (& args )
400
401
401
402
// Convert string to int because id is int
402
403
pipelineID , err := strconv .Atoi (pipelineIDStr )
@@ -406,9 +407,9 @@ func PipelineStart(c echo.Context) error {
406
407
407
408
// Look up pipeline for the given id
408
409
var foundPipeline gaia.Pipeline
409
- for _ , pipeline := range pipeline .GlobalActivePipelines .GetAll () {
410
- if pipeline .ID == pipelineID {
411
- foundPipeline = pipeline
410
+ for _ , p := range pipeline .GlobalActivePipelines .GetAll () {
411
+ if p .ID == pipelineID {
412
+ foundPipeline = p
412
413
break
413
414
}
414
415
}
@@ -440,16 +441,16 @@ func PipelineGetAllWithLatestRun(c echo.Context) error {
440
441
441
442
// Iterate all pipelines
442
443
var pipelinesWithLatestRun []getAllWithLatestRun
443
- for _ , pipeline := range pipelines {
444
+ for _ , p := range pipelines {
444
445
// Get the latest run by the given pipeline id
445
- run , err := storeService .PipelineGetLatestRun (pipeline .ID )
446
+ run , err := storeService .PipelineGetLatestRun (p .ID )
446
447
if err != nil {
447
448
return c .String (http .StatusInternalServerError , err .Error ())
448
449
}
449
450
450
451
// Append run if one exists
451
452
g := getAllWithLatestRun {}
452
- g .Pipeline = pipeline
453
+ g .Pipeline = p
453
454
if run != nil {
454
455
g .PipelineRun = * run
455
456
}
@@ -463,7 +464,7 @@ func PipelineGetAllWithLatestRun(c echo.Context) error {
463
464
464
465
// PipelineCheckPeriodicSchedules validates the added periodic schedules.
465
466
func PipelineCheckPeriodicSchedules (c echo.Context ) error {
466
- pSchedules := []string {}
467
+ var pSchedules []string
467
468
if err := c .Bind (& pSchedules ); err != nil {
468
469
return c .String (http .StatusBadRequest , err .Error ())
469
470
}
0 commit comments