From 3ce008c97eea6d7e4dc20d5bae350a9c52269ecb Mon Sep 17 00:00:00 2001 From: RPJosh Date: Fri, 6 Jan 2023 18:40:39 +0100 Subject: [PATCH] Add custom location for jobs and fix exec of jobs --- .gitignore | 2 +- Jenkinsfile | 7 ++++--- cmd/ncDocConverth/main.go | 3 ++- configs/config.yaml | 3 +++ internal/models/webconfig.go | 2 ++ internal/ncworker/convertscheduler.go | 4 ++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c0d651a..c2f2b55 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,5 @@ go.work # Build binaries /ncDocConverth-* -# Note folder +# Space for private notes /notes \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index a539511..e21cbb8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,9 +27,10 @@ pipeline { } stage('Deploy') { - when { - buildingTag() - } + // Tags not working with gitea? + //when { + // buildingTag() + //} steps { script { diff --git a/cmd/ncDocConverth/main.go b/cmd/ncDocConverth/main.go index f394fc4..6dafdbb 100644 --- a/cmd/ncDocConverth/main.go +++ b/cmd/ncDocConverth/main.go @@ -53,13 +53,14 @@ func main() { WriteTimeout: 10 * time.Second, } - ncConvertUsers, err := models.ParseConvertUsers("./ncConverter.json") + ncConvertUsers, err := models.ParseConvertUsers(webApp.config.Server.JobFile) if err != nil { logger.Error("Unable to parse the file %s: %s", "dd", err) } ncworker.NewScheduler(ncConvertUsers, config) if 1 == 1 { + // Webserver for BookStack hooks currently not implemented return } diff --git a/configs/config.yaml b/configs/config.yaml index e1cbe82..e71dd8b 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -9,6 +9,9 @@ server: # Afterward the program does exit -> The "execution" field in the jobs are going to be ignored oneShot: false + # Location of the file with the job configurations + JobFile: "./ncConverter.json" + logging: # Minimum log Level for printing to the console (debug, info, warning, error, fatal) printLogLevel: info diff --git a/internal/models/webconfig.go b/internal/models/webconfig.go index 0720c0f..6ecf7e7 100644 --- a/internal/models/webconfig.go +++ b/internal/models/webconfig.go @@ -18,6 +18,7 @@ type Server struct { Address string `yaml:"address"` Certificate string `yaml:"certificate"` OneShot bool `yaml:"oneShot"` + JobFile string `yaml:"JobFile"` Version string } @@ -49,6 +50,7 @@ func getDefaultConfig() *WebConfig { return &WebConfig{ Server: Server{ Address: ":4000", + JobFile: "./ncConverter.json", }, Logging: Logging{ PrintLogLevel: "info", diff --git a/internal/ncworker/convertscheduler.go b/internal/ncworker/convertscheduler.go index c51b702..4b151ff 100644 --- a/internal/ncworker/convertscheduler.go +++ b/internal/ncworker/convertscheduler.go @@ -87,7 +87,7 @@ func (s NcConvertScheduler) ScheduleExecutions() { // Schedule Nextcloud jobs for i, job := range user.ConvertJobs { - convJob := NewNcJob(&s.users.Users[ui].ConvertJobs[i], &s.users.Users[i]) + convJob := NewNcJob(&s.users.Users[ui].ConvertJobs[i], &s.users.Users[ui]) _, err := s.scheduler.Cron(job.Execution).DoWithJobDetails(s.executeJob, convJob) if err != nil { @@ -98,7 +98,7 @@ func (s NcConvertScheduler) ScheduleExecutions() { // Schedule boockstack jobs if user.BookStack.URL != "" { for i, job := range user.BookStack.Jobs { - bsJob := NewBsJob(&s.users.Users[ui].BookStack.Jobs[i], &s.users.Users[i]) + bsJob := NewBsJob(&s.users.Users[ui].BookStack.Jobs[i], &s.users.Users[ui]) _, err := s.scheduler.Cron(job.Execution).DoWithJobDetails(s.executeJob, bsJob) if err != nil {