Skip to content

Commit

Permalink
minor: LUMIGO_TRACER_TOKEN instead of LUMIGO_TOKEN (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirLumigo authored Apr 4, 2022
1 parent e44d80e commit 4c68e5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 3 additions & 3 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion scripts/checks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -eo pipefail

make checks
export GOPATH=$(go env GOPATH)
make checks

0 comments on commit 4c68e5d

Please sign in to comment.