about summary refs log tree commit diff
path: root/ops/besadii
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-11-28T08·29+0300
committertazjin <mail@tazj.in>2021-11-28T10·34+0000
commit104f002a07360dc9340d15dfb6b2d044fd043754 (patch)
treeef367c9282ea26e9e21a1f517a0fd5aa2b1fd462 /ops/besadii
parent465f3d3f14910797a0ae645fc200ebf35a9ac79c (diff)
fix(ops/besadii): Trim whitespace of auth tokens r/3102
This is causing failures when trying to update Sourcegraph at least,
for good measure I've trimmed both.

Change-Id: I40266ee83b4e266ffe50f16bb365eb2e51952513
Diffstat (limited to 'ops/besadii')
-rw-r--r--ops/besadii/main.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/ops/besadii/main.go b/ops/besadii/main.go
index f86275750473..9a1befa0230b 100644
--- a/ops/besadii/main.go
+++ b/ops/besadii/main.go
@@ -25,6 +25,7 @@ import (
 	"os"
 	"path"
 	"regexp"
+	"strings"
 )
 
 var branchRegexp = regexp.MustCompile(`^refs/heads/(.*)$`)
@@ -259,24 +260,26 @@ func refUpdatedMain() {
 		os.Exit(0)
 	}
 
-	buildkiteToken, err := ioutil.ReadFile("/etc/secrets/buildkite-besadii")
+	buildkiteTokenBytes, err := ioutil.ReadFile("/etc/secrets/buildkite-besadii")
 	if err != nil {
 		log.Alert(fmt.Sprintf("buildkite token could not be read: %s", err))
 		os.Exit(1)
 	}
+	buildkiteToken := strings.TrimSpace(string(buildkiteTokenBytes))
 
-	sourcegraphToken, err := ioutil.ReadFile("/etc/secrets/sourcegraph-token")
+	sourcegraphTokenBytes, err := ioutil.ReadFile("/etc/secrets/sourcegraph-token")
 	if err != nil {
 		log.Alert(fmt.Sprintf("sourcegraph token could not be read: %s", err))
 		os.Exit(1)
 	}
+	sourcegraphToken := strings.TrimSpace(string(sourcegraphTokenBytes))
 
-	err = triggerBuild(log, string(buildkiteToken), update)
+	err = triggerBuild(log, buildkiteToken, update)
 	if err != nil {
 		log.Err(fmt.Sprintf("failed to trigger Buildkite build: %s", err))
 	}
 
-	err = triggerIndexUpdate(string(sourcegraphToken))
+	err = triggerIndexUpdate(sourcegraphToken)
 	if err != nil {
 		log.Err(fmt.Sprintf("failed to trigger sourcegraph index update: %s", err))
 	}