From 00bc6ecd92bdc9307712805f268c9fcf72798701 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Fri, 29 Apr 2022 16:28:50 -0700 Subject: [PATCH] make sure we can pull config from env variables. --- .github/workflows/build.yaml | 1 + webapp/backend/pkg/config/config.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 14ad185..064b177 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -24,6 +24,7 @@ jobs: env: PROJECT_PATH: /go/src/github.com/analogj/scrutiny CGO_ENABLED: 1 + SCRUTINY_WEB_INFLUXDB_HOST: influxdb steps: - name: Git run: | diff --git a/webapp/backend/pkg/config/config.go b/webapp/backend/pkg/config/config.go index 27e1c05..31243e9 100644 --- a/webapp/backend/pkg/config/config.go +++ b/webapp/backend/pkg/config/config.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/viper" "log" "os" + "strings" ) // When initializing this class the following methods must be called: @@ -64,6 +65,11 @@ func (c *configuration) Init() error { //c.SetConfigName("drawbridge") //c.AddConfigPath("$HOME/") + //configure env variable parsing. + c.SetEnvPrefix("SCRUTINY") + c.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) + c.AutomaticEnv() + //CLI options will be added via the `Set()` function return nil }