From 6842e25f14a463d0f7e7ad7d9ebe700a7efabb7a Mon Sep 17 00:00:00 2001 From: Åsmund Østvold Date: Mon, 13 Dec 2021 11:32:40 +0100 Subject: feat(besadii): Make Gerrit label configurable 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 Change-Id: I254159e46994e01182987ed5e5e26e27c57f46ce --- ops/besadii/main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'ops/besadii/main.go') diff --git a/ops/besadii/main.go b/ops/besadii/main.go index ef4f4fe424..5567251852 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", } -- cgit 1.4.1