config: fix connstr for remote_cache (#17675)

fixes #17643 and adds test to check for commented out lines (but will only catch `;`, not `#`).

(cherry picked from commit 49f0f0e89e)
This commit is contained in:
Kyle Brandt
2019-06-25 13:56:19 -04:00
committed by Kyle Brandt
parent 095c4cab6a
commit cb6e6de6a7
2 changed files with 21 additions and 2 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ type = database
# database: will use Grafana primary database.
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0`. Only addr is required.
# memcache: 127.0.0.1:11211
;connstr =
connstr =
#################################### Data proxy ###########################
[dataproxy]
+20 -1
View File
@@ -1,13 +1,16 @@
package setting
import (
"gopkg.in/ini.v1"
"bufio"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"
"gopkg.in/ini.v1"
. "github.com/smartystreets/goconvey/convey"
)
@@ -25,6 +28,22 @@ func TestLoadingSettings(t *testing.T) {
So(cfg.RendererCallbackUrl, ShouldEqual, "http://localhost:3000/")
})
Convey("default.ini should have no semi-colon commented entries", func() {
file, err := os.Open("../../conf/defaults.ini")
if err != nil {
t.Errorf("failed to load defaults.ini file: %v", err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
// This only catches values commented out with ";" and will not catch those that are commented out with "#".
if strings.HasPrefix(scanner.Text(), ";") {
t.Errorf("entries in defaults.ini must not be commented or environment variables will not work: %v", scanner.Text())
}
}
})
Convey("Should be able to override via environment variables", func() {
os.Setenv("GF_SECURITY_ADMIN_USER", "superduper")