Job exection logic now runs pipeline in container
This container's network is configured based on parameters in the config file. If configured correctly, this will allow the pipeline script to speak to the cursorius server over the pipeline api.
This commit is contained in:
+8
-6
@@ -6,13 +6,14 @@ import (
|
||||
|
||||
"git.ohea.xyz/cursorius/server/config"
|
||||
"git.ohea.xyz/cursorius/server/jobscheduler"
|
||||
"git.ohea.xyz/cursorius/server/pipeline_executor"
|
||||
"github.com/go-playground/webhooks/v6/gitea"
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
|
||||
var log = logging.MustGetLogger("cursorius-server")
|
||||
|
||||
func CreateWebhookHandler(runCh chan jobscheduler.Run, jobs map[string]config.Job, mux *http.ServeMux) {
|
||||
func CreateWebhookHandler(runCh chan jobscheduler.Run, conf config.Config, mux *http.ServeMux) {
|
||||
mux.HandleFunc("/webhook/", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
@@ -26,7 +27,7 @@ func CreateWebhookHandler(runCh chan jobscheduler.Run, jobs map[string]config.Jo
|
||||
// TODO: verify that this handles all valid URL formats
|
||||
webhookJobName := splitUrl[2]
|
||||
|
||||
for jobName, jobConfig := range jobs {
|
||||
for jobName, jobConfig := range conf.Jobs {
|
||||
if webhookJobName == jobName {
|
||||
if jobConfig.Webhook == nil {
|
||||
log.Errorf("Matching job does not have webhook configuration, ignoring....")
|
||||
@@ -54,12 +55,13 @@ func CreateWebhookHandler(runCh chan jobscheduler.Run, jobs map[string]config.Jo
|
||||
case gitea.PushPayload:
|
||||
pushPayload := payload.(gitea.PushPayload)
|
||||
|
||||
runCh <- jobscheduler.Run{
|
||||
JobName: jobName,
|
||||
JobConfig: jobConfig,
|
||||
Ref: pushPayload.Ref,
|
||||
pe := pipeline_executor.PipelineExecution{
|
||||
Name: webhookJobName,
|
||||
Job: jobConfig,
|
||||
Ref: pushPayload.Ref,
|
||||
}
|
||||
|
||||
pipeline_executor.ExecutePipeline(pe, conf.PipelineConf)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user