From 8586d930a3f4a8235d6383e90bbcd22762060126 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 3 Jan 2023 14:35:36 +0100 Subject: config: Ensure we always have an absolute path Having this consistent across the code is handy when we're building paths, counting separators and other path manipulation. --- config/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/config.go b/config/config.go index 3119352..7c38341 100644 --- a/config/config.go +++ b/config/config.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "path/filepath" "gopkg.in/yaml.v3" ) @@ -40,5 +41,15 @@ func Read(f string) (*Config, error) { return nil, fmt.Errorf("parsing config: %w", err) } + if c.Repo.ScanPath, err = filepath.Abs(c.Repo.ScanPath); err != nil { + return nil, err + } + if c.Dirs.Templates, err = filepath.Abs(c.Dirs.Templates); err != nil { + return nil, err + } + if c.Dirs.Static, err = filepath.Abs(c.Dirs.Static); err != nil { + return nil, err + } + return &c, nil } -- cgit