From 65b087bcc1bdf55334fe6c1f834db6e7f1013112 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 4 Jul 2017 11:06:02 +0200 Subject: [PATCH] config: resolve file SD paths relative to config --- config/config.go | 5 +++++ config/config_test.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 93d2ecd4d..5b35e7a92 100644 --- a/config/config.go +++ b/config/config.go @@ -281,6 +281,11 @@ func resolveFilepaths(baseDir string, cfg *Config) { consulcfg.TLSConfig.CertFile = join(consulcfg.TLSConfig.CertFile) consulcfg.TLSConfig.KeyFile = join(consulcfg.TLSConfig.KeyFile) } + for _, filecfg := range cfg.FileSDConfigs { + for i, fn := range filecfg.Files { + filecfg.Files[i] = join(fn) + } + } } for _, cfg := range cfg.ScrapeConfigs { diff --git a/config/config_test.go b/config/config_test.go index 0282deb0e..2a5c53232 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -104,11 +104,11 @@ var expectedConf = &Config{ FileSDConfigs: []*FileSDConfig{ { - Files: []string{"foo/*.slow.json", "foo/*.slow.yml", "single/file.yml"}, + Files: []string{"testdata/foo/*.slow.json", "testdata/foo/*.slow.yml", "testdata/single/file.yml"}, RefreshInterval: model.Duration(10 * time.Minute), }, { - Files: []string{"bar/*.yaml"}, + Files: []string{"testdata/bar/*.yaml"}, RefreshInterval: model.Duration(5 * time.Minute), }, },