Skip to content

Commit

Permalink
Merge pull request #79 from hazelops/feature/read-common-env-vars
Browse files Browse the repository at this point in the history
Main environment parameters read from conventional env vars (TOOLS-186)
  • Loading branch information
AutomationD authored Jan 15, 2022
2 parents e2573f2 + e35f472 commit 6678abc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func InitializeConfig() error {
return err
}

viper.SetDefault("ENV", os.Getenv("ENV"))
viper.SetDefault("AWS_PROFILE", os.Getenv("AWS_PROFILE"))
viper.SetDefault("AWS_REGION", os.Getenv("AWS_REGION"))
viper.SetDefault("NAMESPACE", os.Getenv("NAMESPACE"))

if viper.GetString("config-file") != "" {
_, err := initConfig(viper.GetString("config-file"))
if err != nil {
Expand All @@ -129,7 +134,7 @@ func InitializeConfig() error {
if len(viper.GetString("aws-profile")) == 0 {
viper.Set("aws-profile", viper.GetString("aws_profile"))
if len(viper.GetString("aws-profile")) == 0 {
return fmt.Errorf("AWS profile must be specified using flags or config file")
return fmt.Errorf("AWS profile must be specified using flags, config file or env var")
}
}

Expand Down

0 comments on commit 6678abc

Please sign in to comment.