update sanity check when parsing config

This commit is contained in:
shoopea 2023-06-29 23:20:46 +02:00
parent 7e8a34a435
commit 3c785dec8b
3 changed files with 20 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"regexp"
"sync"
"time"
@ -132,6 +133,20 @@ func (c *Config) LoadFile(path string) error {
return err
}
c.apps[v.Name] = a
for k, _ := range a.schedule {
if dur, ok := c.ScheduleDuration[k]; ok {
re := regexp.MustCompile(`^forever|([0-9]+(h|d|m|y))+$`)
if !re.MatchString(dur) {
err := errors.New("incorrect schedule duration")
log.WithFields(log.Fields{"path": path, "app": v.Name, "schedule": k, "error": err}).Errorf("")
return err
}
} else {
err := errors.New("undefined schedule duration")
log.WithFields(log.Fields{"path": path, "app": v.Name, "schedule": k, "error": err}).Errorf("")
return err
}
}
}
}

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "fb02d52"
var githash = "7e8a34a"
var branch = "v2"
var buildstamp = "2023-06-29_20:53:51"
var commits = "55"
var version = "fb02d52-b55 - 2023-06-29_20:53:51"
var buildstamp = "2023-06-29_21:19:42"
var commits = "57"
var version = "7e8a34a-b57 - 2023-06-29_21:19:42"

View File

@ -2,7 +2,7 @@
githash=`git rev-parse --short HEAD`
branch=`git rev-parse --abbrev-ref HEAD`
buildstamp=`date -u '+%Y-%m-%d_%H:%M:%S'`
commits=`git rev-list --count master`
commits=`git rev-list --count $branch`
# Write out the package.
cat << EOF > version.go
// Code generated by version.sh (@generated) DO NOT EDIT.