Skip to content

Commit

Permalink
Merge pull request #24 from vibrato/fix-config-white-space
Browse files Browse the repository at this point in the history
Now trims whitespace from configuration values in environment variables and configuration file
  • Loading branch information
TWinsnes authored Aug 25, 2018
2 parents 6e87f93 + 000987b commit 05ae5ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var rootCmd = &cobra.Command{
This application is used as part of testing potential candiates at Vibrato.
Please visit http://vibrato.com.au for more details`,
Version: "0.3.3",
Version: "0.3.4",
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
16 changes: 9 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package config

import (
"strings"

"github.com/spf13/viper"
)

Expand Down Expand Up @@ -63,13 +65,13 @@ func LoadConfig() (*Config, error) {
return nil, err
}

conf.DbUser = v.GetString("DbUser")
conf.DbPassword = v.GetString("DbPassword")
conf.DbName = v.GetString("DbName")
conf.DbHost = v.GetString("DbHost")
conf.DbPort = v.GetString("DbPort")
conf.ListenHost = v.GetString("ListenHost")
conf.ListenPort = v.GetString("ListenPort")
conf.DbUser = strings.TrimSpace(v.GetString("DbUser"))
conf.DbPassword = strings.TrimSpace(v.GetString("DbPassword"))
conf.DbName = strings.TrimSpace(v.GetString("DbName"))
conf.DbHost = strings.TrimSpace(v.GetString("DbHost"))
conf.DbPort = strings.TrimSpace(v.GetString("DbPort"))
conf.ListenHost = strings.TrimSpace(v.GetString("ListenHost"))
conf.ListenPort = strings.TrimSpace(v.GetString("ListenPort"))

return conf, nil
}

0 comments on commit 05ae5ce

Please sign in to comment.