Skip to content

Commit 242997d

Browse files
committed
Added the functionality to save a drop-in pipeline.
1 parent 08f90cf commit 242997d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

cmd/gaia/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func init() {
4444
flag.BoolVar(&gaia.Cfg.DevMode, "dev", false, "If true, gaia will be started in development mode. Don't use this in production!")
4545
flag.BoolVar(&gaia.Cfg.VersionSwitch, "version", false, "If true, will print the version and immediately exit")
4646
flag.BoolVar(&gaia.Cfg.Poll, "poll", false, "Instead of using a Webhook, keep polling git for changes on pipelines")
47-
flag.IntVar(&gaia.Cfg.PVal, "pval", 1, "The interval in minutes in which to poll Github for changes")
47+
flag.IntVar(&gaia.Cfg.PVal, "pval", 1, "The interval in minutes in which to poll vcs for changes")
4848
// Default values
4949
gaia.Cfg.Bolt.Mode = 0600
5050
}

pipeline/git_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestUpdateAllPipelinesAlreadyUpToDateWithMoreThanOnePipeline(t *testing.T)
116116
}
117117
}
118118

119-
func TestUpdateAllPipelinesTenPipelines(t *testing.T) {
119+
func TestUpdateAllPipelinesHundredPipelines(t *testing.T) {
120120
if _, ok := os.LookupEnv("GAIA_RUN_HUNDRED_PIPELINE_TEST"); !ok {
121121
t.Skip()
122122
}

pipeline/ticker.go

+17
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ func checkActivePipelines() {
135135
continue
136136
}
137137

138+
// Pipeline is a drop-in build. Set up a template for it.
139+
shouldStore := false
140+
if pipeline == nil {
141+
pipeline = &gaia.Pipeline{
142+
Name: pName,
143+
Type: pType,
144+
ExecPath: filepath.Join(gaia.Cfg.PipelinePath, file.Name()),
145+
Created: time.Now(),
146+
}
147+
shouldStore = true
148+
}
149+
138150
// We calculate a SHA256 Checksum and store it.
139151
// We use this to estimate if a pipeline has been changed.
140152
pipeline.SHA256Sum, err = getSHA256Sum(pipeline.ExecPath)
@@ -146,6 +158,11 @@ func checkActivePipelines() {
146158
// Let us try to start the plugin and receive all implemented jobs
147159
schedulerService.SetPipelineJobs(pipeline)
148160

161+
// We encountered a drop-in pipeline previously. Now is the time to save it.
162+
if shouldStore {
163+
storeService.PipelinePut(pipeline)
164+
}
165+
149166
// We do not update the pipeline in store if it already exists there.
150167
// We only updated the SHA256 Checksum and the jobs but this is not importent
151168
// to store and should not have any side effects.

0 commit comments

Comments
 (0)