Skip to content

Commit 5c72a1e

Browse files
Split envString function
1 parent 333cc2c commit 5c72a1e

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

  • internal/app/traefik-github-oauth-server

internal/app/traefik-github-oauth-server/config.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ type Config struct {
1919
GithubOauthScopes []string
2020
}
2121

22-
func envString(key string) string {
23-
fileKey := key + "_FILE"
24-
if value := os.Getenv(fileKey); value != "" {
22+
func envFromFile(key string) string {
23+
fileEnvKey := key + "_FILE"
24+
25+
if value := os.Getenv(fileEnvKey); value != "" {
2526
content, err := os.ReadFile(value)
26-
if err != nil {
27-
return os.Getenv(key)
27+
if err == nil {
28+
return strings.TrimSpace(string(content))
2829
}
29-
return strings.TrimSpace(string(content))
30+
}
31+
return ""
32+
}
33+
34+
func envString(key string) string {
35+
if value := envFromFile(key); value != "" {
36+
return value
3037
}
3138
return os.Getenv(key)
3239
}

0 commit comments

Comments
 (0)