From caf653be32f051e7f738a3aa08117df4d9ef6a14 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 23 Aug 2024 14:14:53 +0300 Subject: [PATCH] chore(ops/besadii): remove sourcegraph index update support Change-Id: I4ee9a5a69c90e2050c60b2ef8483431d691b499f Reviewed-on: https://cl.tvl.fyi/c/depot/+/12287 Tested-by: BuildkiteCI Reviewed-by: flokli --- ops/besadii/default.nix | 2 +- ops/besadii/main.go | 37 ------------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/ops/besadii/default.nix b/ops/besadii/default.nix index 1199c56cf..424fa19b2 100644 --- a/ops/besadii/default.nix +++ b/ops/besadii/default.nix @@ -1,5 +1,5 @@ # This program is used as a Gerrit hook to trigger builds on -# Buildkite, Sourcegraph reindexing and other maintenance tasks. +# Buildkite and perform other maintenance tasks. { depot, ... }: depot.nix.buildGo.program { diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 809acc29e..aacd8f176 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -8,7 +8,6 @@ // // Gerrit (ref-updated) hook: // - Trigger Buildkite CI builds -// - Trigger SourceGraph repository index updates // // Buildkite (post-command) hook: // - Submit CL verification status back to Gerrit @@ -55,10 +54,6 @@ type config struct { BuildkiteProject string `json:"buildkiteProject"` BuildkiteToken string `json:"buildkiteToken"` GerritChangeName string `json:"gerritChangeName"` - - // Optional configuration for Sourcegraph trigger updates. - SourcegraphUrl string `json:"sourcegraphUrl"` - SourcegraphToken string `json:"sourcegraphToken"` } // buildTrigger represents the information passed to besadii when it @@ -154,11 +149,6 @@ func loadConfig() (*config, error) { return nil, fmt.Errorf("invalid 'gerritChangeName': %s", cfg.GerritChangeName) } - // Rudimentary config validation logic - if cfg.SourcegraphUrl != "" && cfg.SourcegraphToken == "" { - 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)") } @@ -299,26 +289,6 @@ func triggerBuild(cfg *config, log *syslog.Writer, trigger *buildTrigger) error return nil } -// Trigger a Sourcegraph repository index update. -// -// https://docs.sourcegraph.com/admin/repo/webhooks -func triggerIndexUpdate(cfg *config, log *syslog.Writer) error { - req, err := http.NewRequest("POST", cfg.SourcegraphUrl, nil) - if err != nil { - return err - } - - req.Header.Add("Authorization", "token "+cfg.SourcegraphToken) - - _, err = http.DefaultClient.Do(req) - if err != nil { - return fmt.Errorf("failed to trigger Sourcegraph index update: %w", err) - } - - log.Info("triggered sourcegraph index update") - return nil -} - // Gerrit passes more flags than we want, but Rob Pike decided[0] in // 2013 that the Go art project will not allow users to ignore flags // because he "doesn't like it". This function allows users to ignore @@ -458,13 +428,6 @@ func gerritHookMain(cfg *config, log *syslog.Writer, trigger *buildTrigger) { if err != nil { log.Err(fmt.Sprintf("failed to trigger Buildkite build: %s", err)) } - - if cfg.SourcegraphUrl != "" && trigger.ref == cfg.Branch { - err = triggerIndexUpdate(cfg, log) - if err != nil { - log.Err(fmt.Sprintf("failed to trigger sourcegraph index update: %s", err)) - } - } } func postCommandMain(cfg *config) {