aboutsummaryrefslogtreecommitdiffstats
path: root/syz-ci/manager.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-01-12 11:47:40 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-01-12 12:33:22 +0000
commitf6fa7c2845ca01940da7571219da2203c579068d (patch)
tree4eb1473f8eee8c473bfe1b6031868b0e944b6a4d /syz-ci/manager.go
parentc9aa7b7def60823283a7fd261940c0a05d3ce850 (diff)
syz-ci: refactor loadManagerConfig()
The linters are complaining about a too high cyclomatic complexity. Split out a ManagerConfig.validate() method.
Diffstat (limited to 'syz-ci/manager.go')
-rw-r--r--syz-ci/manager.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/syz-ci/manager.go b/syz-ci/manager.go
index f125e2e1a..d21a2a67f 100644
--- a/syz-ci/manager.go
+++ b/syz-ci/manager.go
@@ -14,6 +14,7 @@ import (
"os"
"path"
"path/filepath"
+ "regexp"
"strings"
"time"
@@ -917,3 +918,21 @@ func (mgr *Manager) Errorf(msg string, args ...interface{}) {
mgr.dash.LogError(mgr.name, msg, args...)
}
}
+
+func (mgr *ManagerConfig) validate(cfg *Config) error {
+ // Manager name must not contain dots because it is used as GCE image name prefix.
+ managerNameRe := regexp.MustCompile("^[a-zA-Z0-9-_]{3,64}$")
+ if !managerNameRe.MatchString(mgr.Name) {
+ return fmt.Errorf("param 'managers.name' has bad value: %q", mgr.Name)
+ }
+ if mgr.Jobs.AnyEnabled() && (cfg.DashboardAddr == "" || cfg.DashboardClient == "") {
+ return fmt.Errorf("manager %v: has jobs but no dashboard info", mgr.Name)
+ }
+ if mgr.Jobs.PollCommits && (cfg.DashboardAddr == "" || mgr.DashboardClient == "") {
+ return fmt.Errorf("manager %v: commit_poll is set but no dashboard info", mgr.Name)
+ }
+ if (mgr.Jobs.BisectCause || mgr.Jobs.BisectFix) && cfg.BisectBinDir == "" {
+ return fmt.Errorf("manager %v: enabled bisection but no bisect_bin_dir", mgr.Name)
+ }
+ return nil
+}