1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

Make all secrets case insensitive by formatting them to uppercase (#470)

* Uppercase secrets, print error when secret with same name already exists

* Test lower-to-upper case formatting for secrets
This commit is contained in:
Cat™ 2021-01-12 17:54:53 +00:00 committed by GitHub
parent 501e2e4d5f
commit 078494e07c
3 changed files with 15 additions and 0 deletions

View file

@ -15,6 +15,10 @@ func newSecrets(secretList []string) secrets {
s := make(map[string]string)
for _, secretPair := range secretList {
secretPairParts := strings.SplitN(secretPair, "=", 2)
secretPairParts[0] = strings.ToUpper(secretPairParts[0])
if strings.ToUpper(s[secretPairParts[0]]) == secretPairParts[0] {
log.Fatalf("Secret %s is already defined (secrets are case insensitive)", secretPairParts[0])
}
if len(secretPairParts) == 2 {
s[secretPairParts[0]] = secretPairParts[1]
} else if env, ok := os.LookupEnv(secretPairParts[0]); ok && env != "" {