diff --git a/config.go b/config.go index db1a8b7..ea654bc 100644 --- a/config.go +++ b/config.go @@ -35,20 +35,20 @@ func (cfg Config) validate() error { // nolint // init not really used right now func init() { viper.AutomaticEnv() - viper.SetEnvPrefix("lumigo") - viper.SetDefault("Enabled", true) - viper.SetDefault("Debug", false) + viper.SetEnvPrefix("LUMIGO") + viper.SetDefault("ENABLED", true) + viper.SetDefault("DEBUG", false) } func loadConfig(conf Config) error { defer recoverWithLogs() - cfg.Token = viper.GetString("Token") + cfg.Token = viper.GetString("TRACER_TOKEN") if cfg.Token == "" { cfg.Token = conf.Token } - cfg.enabled = viper.GetBool("Enabled") - cfg.debug = viper.GetBool("Debug") + cfg.enabled = viper.GetBool("ENABLED") + cfg.debug = viper.GetBool("DEBUG") cfg.PrintStdout = conf.PrintStdout return cfg.validate() } diff --git a/config_test.go b/config_test.go index 6ef1e77..d82e9ca 100644 --- a/config_test.go +++ b/config_test.go @@ -17,7 +17,7 @@ func TestSetupConfSuite(t *testing.T) { } func (conf *configTestSuite) TearDownTest() { - os.Unsetenv("LUMIGO_TOKEN") + os.Unsetenv("LUMIGO_TRACER_TOKEN") os.Unsetenv("LUMIGO_DEBUG") os.Unsetenv("LUMIGO_ENABLED") } @@ -27,7 +27,7 @@ func (conf *configTestSuite) TestConfigValidationMissingToken() { } func (conf *configTestSuite) TestConfigEnvVariables() { - os.Setenv("LUMIGO_TOKEN", "token") + os.Setenv("LUMIGO_TRACER_TOKEN", "token") os.Setenv("LUMIGO_DEBUG", "true") os.Setenv("LUMIGO_ENABLED", "false") @@ -39,7 +39,7 @@ func (conf *configTestSuite) TestConfigEnvVariables() { } func (conf *configTestSuite) TestConfigEnabledByDefault() { - os.Setenv("LUMIGO_TOKEN", "token") + os.Setenv("LUMIGO_TRACER_TOKEN", "token") err := loadConfig(Config{}) assert.NoError(conf.T(), err) diff --git a/scripts/checks.sh b/scripts/checks.sh index 448aac5..d3354fb 100755 --- a/scripts/checks.sh +++ b/scripts/checks.sh @@ -1,4 +1,5 @@ #!/bin/bash set -eo pipefail -make checks \ No newline at end of file +export GOPATH=$(go env GOPATH) +make checks