1
0
Fork 0
forked from forgejo/forgejo

[BRANDING] parse FORGEJO__* in the container environment

(cherry picked from commit b075991747)
(cherry picked from commit ac8503150a)
This commit is contained in:
Earl Warren 2023-07-10 23:17:39 +02:00
parent 6730fd099d
commit 266948e08a
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 23 additions and 14 deletions

View file

@ -5,6 +5,7 @@ package setting
import (
"os"
"regexp"
"testing"
"github.com/stretchr/testify/assert"
@ -33,7 +34,7 @@ func TestDecodeEnvSectionKey(t *testing.T) {
}
func TestDecodeEnvironmentKey(t *testing.T) {
prefix := "GITEA__"
prefix := regexp.MustCompile(EnvConfigKeyPrefixGitea)
suffix := "__FILE"
ok, section, key, file := decodeEnvironmentKey(prefix, suffix, "SEC__KEY")
@ -54,6 +55,12 @@ func TestDecodeEnvironmentKey(t *testing.T) {
assert.Equal(t, "KEY", key)
assert.False(t, file)
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "FORGEJO__SEC__KEY")
assert.True(t, ok)
assert.Equal(t, "sec", section)
assert.Equal(t, "KEY", key)
assert.False(t, file)
// with "__FILE" suffix, it doesn't support to write "[sec].FILE" to config (no such key FILE is used in Gitea)
// but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used in Gitea either)
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__FILE")