diff options
author | Vincent Ambo <mail@tazj.in> | 2021-11-29T16·06+0300 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2021-12-02T10·10+0300 |
commit | e48ae26e8e8f82f58b30a232a8ea32accb4a8b82 (patch) | |
tree | 0d1adfe9a6f5922f2f74bb9d26ee299b7e91209d /ops/besadii | |
parent | ee635d4645126d0821e75fe71b4e56ec7e119eaa (diff) |
feat(ops/besadii): Add other missing configuration keys r/3135
Adds configuration keys and rudimentary validation for all other besadii settings that are currently hardcoded. This adds the config options: * repository: Name of the repository in Gerrit. * branch: Name of the HEAD branch in the repository. * gerritUrl: Base URL of the Gerrit instance * gerritUser: Username of the Gerrit user * gerritPassword: Password of the Gerrit user * buildkiteOrg: Name of the Buildkite organisation * buildkiteProject: Name of the pipeline inside the Buildkite organisation * buildkiteToken: Auth token for Buildkite access All of these configuration options are required. Change-Id: Ie6b109de9cd8484a3773c6351d7fd140f39a49ed
Diffstat (limited to 'ops/besadii')
-rw-r--r-- | ops/besadii/main.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 3d694800a415..a5a144efea89 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -34,6 +34,18 @@ var changeIdRegexp = regexp.MustCompile(`^.*/(\d+)$`) // besadii configuration file structure type config struct { + // Required configuration for Buildkite<>Gerrit monorepo + // integration. + Repository string `json:"repository"` + Branch string `json:"branch"` + GerritUrl string `json:"gerritUrl"` + GerritUser string `json:"gerritUser"` + GerritPassword string `json:"gerritPassword"` + BuildkiteOrg string `json:"buildkiteOrg"` + BuildkiteProject string `json:"buildkiteProject"` + BuildkiteToken string `json:"buildkiteToken"` + + // Optional configuration for Sourcegraph trigger updates. SourcegraphUrl string `json:"sourcegraphUrl"` SourcegraphToken string `json:"sourcegraphToken"` } @@ -107,6 +119,18 @@ func loadConfig() (*config, error) { return nil, fmt.Errorf("'SourcegraphToken' must be set if 'SourcegraphUrl' is set") } + if cfg.Repository == "" || cfg.Branch == "" { + return nil, fmt.Errorf("missing repository configuration (required: repository, branch)") + } + + if cfg.GerritUrl == "" || cfg.GerritUser == "" || cfg.GerritPassword == "" { + return nil, fmt.Errorf("missing Gerrit configuration (required: gerritUrl, gerritUser, gerritPassword)") + } + + if cfg.BuildkiteOrg == "" || cfg.BuildkiteProject == "" || cfg.BuildkiteToken == "" { + return nil, fmt.Errorf("mising Buildkite configuration (required: buildkiteOrg, buildkiteProject, buildkiteToken)") + } + return &cfg, nil } |