From 550febc5ba520f256fc892ed3c6f80532fd3cf2f Mon Sep 17 00:00:00 2001 From: Johan Siebens Date: Tue, 6 Sep 2022 16:20:44 +0200 Subject: [PATCH] fix: use abs path, giving a proper error when file does not exists --- internal/config/config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index e2f5a10..9772e26 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -7,7 +7,8 @@ import ( "github.com/jsiebens/ionscale/internal/util" "github.com/mitchellh/go-homedir" "gopkg.in/yaml.v3" - "io/ioutil" + "os" + "path/filepath" "strings" tkey "tailscale.com/types/key" "time" @@ -25,7 +26,13 @@ func LoadConfig(path string) (*Config, error) { if err != nil { return nil, err } - b, err := ioutil.ReadFile(expandedPath) + + absPath, err := filepath.Abs(expandedPath) + if err != nil { + return nil, err + } + + b, err := os.ReadFile(absPath) if err != nil { return nil, err }