CLI: Fix config flag being ignored

Passing --config had no effect when passed.  It will now be applied as
the last config file and before any env var overrrides.
This commit is contained in:
Jason Wilder
2015-02-15 14:57:49 -07:00
parent 9223c95481
commit b6428b08d0
8 changed files with 31 additions and 38 deletions

View File

@@ -164,9 +164,13 @@ func loadEnvVariableOverrides() {
}
}
func NewConfigContext() {
func NewConfigContext(config string) {
configFiles := findConfigFiles()
if config != "" {
configFiles = append(configFiles, config)
}
//log.Info("Loading config files: %v", configFiles)
var err error

View File

@@ -15,7 +15,7 @@ func TestLoadingSettings(t *testing.T) {
Convey("Testing loading settings from ini file", t, func() {
Convey("Given the default ini files", func() {
NewConfigContext()
NewConfigContext("")
So(AppName, ShouldEqual, "Grafana")
So(AdminUser, ShouldEqual, "admin")
@@ -23,7 +23,7 @@ func TestLoadingSettings(t *testing.T) {
Convey("Should be able to override via environment variables", func() {
os.Setenv("GF_SECURITY_ADMIN_USER", "superduper")
NewConfigContext()
NewConfigContext("")
So(AdminUser, ShouldEqual, "superduper")
})