diff options
author | Åsmund Østvold <asmundo@gmail.com> | 2021-12-13T10·32+0100 |
---|---|---|
committer | Åsmund Østvold <asmundo@gmail.com> | 2021-12-14T08·28+0100 |
commit | 6842e25f14a463d0f7e7ad7d9ebe700a7efabb7a (patch) | |
tree | 7efd2951549080a8de6799e1e47520cb7f8c0852 /ops/besadii | |
parent | 0286d63df7fbb267a4dc00f682acb2e2425321b3 (diff) |
feat(besadii): Make Gerrit label configurable r/3237
By default besadii will set the `Verified` label in Gerrit. This adds a config option to set a different label instead if desired. Co-authored-by: Vincent Ambo <mail@tazj.in> Change-Id: I254159e46994e01182987ed5e5e26e27c57f46ce
Diffstat (limited to 'ops/besadii')
-rw-r--r-- | ops/besadii/main.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ops/besadii/main.go b/ops/besadii/main.go index ef4f4fe42489..556725185212 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -42,6 +42,7 @@ type config struct { GerritUrl string `json:"gerritUrl"` GerritUser string `json:"gerritUser"` GerritPassword string `json:"gerritPassword"` + GerritLabel string `json:"gerritLabel"` BuildkiteOrg string `json:"buildkiteOrg"` BuildkiteProject string `json:"buildkiteProject"` BuildkiteToken string `json:"buildkiteToken"` @@ -130,6 +131,11 @@ func loadConfig() (*config, error) { return nil, fmt.Errorf("failed to unmarshal besadii config: %w", err) } + // The default Gerrit label to set is 'Verified', unless specified otherwise. + if cfg.GerritLabel == "" { + cfg.GerritLabel = "Verified" + } + // Rudimentary config validation logic if cfg.SourcegraphUrl != "" && cfg.SourcegraphToken == "" { return nil, fmt.Errorf("'SourcegraphToken' must be set if 'SourcegraphUrl' is set") @@ -441,14 +447,14 @@ func postCommandMain(cfg *config) { return } - var verified int + var vote int var verb string if os.Getenv("BUILDKITE_COMMAND_EXIT_STATUS") == "0" { - verified = 1 // Verified: +1 in Gerrit + vote = 1 // automation passed: +1 in Gerrit verb = "passed" } else { - verified = -1 + vote = -1 verb = "failed" } @@ -457,11 +463,11 @@ func postCommandMain(cfg *config) { Message: msg, OmitDuplicateComments: true, Labels: map[string]int{ - "Verified": verified, + cfg.GerritLabel: vote, }, // Update the attention set if we are failing this patchset. - IgnoreDefaultAttentionSetRules: verified == 1, + IgnoreDefaultAttentionSetRules: vote == 1, Tag: "autogenerated:buildkite~result", } |