diff --git a/ops/besadii/main.go b/ops/besadii/main.go index ef4f4fe42..556725185 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", }