From 05488d59c3d40220c5063019137b008b0c8d7115 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 19 May 2020 08:44:33 +1000 Subject: [PATCH] Find scrapers in subdirectories (#554) --- pkg/scraper/scrapers.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/scraper/scrapers.go b/pkg/scraper/scrapers.go index 14025c3f2..da24a313e 100644 --- a/pkg/scraper/scrapers.go +++ b/pkg/scraper/scrapers.go @@ -2,6 +2,7 @@ package scraper import ( "errors" + "os" "path/filepath" "strconv" @@ -21,7 +22,13 @@ func loadScrapers() ([]scraperConfig, error) { scrapers = make([]scraperConfig, 0) logger.Debugf("Reading scraper configs from %s", path) - scraperFiles, err := filepath.Glob(filepath.Join(path, "*.yml")) + scraperFiles := []string{} + err := filepath.Walk(path, func(fp string, f os.FileInfo, err error) error { + if filepath.Ext(fp) == ".yml" { + scraperFiles = append(scraperFiles, fp) + } + return nil + }) if err != nil { logger.Errorf("Error reading scraper configs: %s", err.Error())