backend: Move environment based configuration into backend

This commit is contained in:
Michael Eischer
2023-04-15 10:25:45 +02:00
parent 49a6a4f5bf
commit 2f7b4ceae1
5 changed files with 84 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
package gs
import (
"os"
"path"
"strings"
@@ -56,3 +57,12 @@ func ParseConfig(s string) (interface{}, error) {
cfg.Prefix = prefix
return cfg, nil
}
// ApplyEnvironment saves values from the environment to the config.
func ApplyEnvironment(cfgRaw interface{}) error {
cfg := cfgRaw.(*Config)
if cfg.ProjectID == "" {
cfg.ProjectID = os.Getenv("GOOGLE_PROJECT_ID")
}
return nil
}