fix: use abs path, giving a proper error when file does not exists

This commit is contained in:
Johan Siebens
2022-09-06 16:20:44 +02:00
parent f0d71c8a66
commit 550febc5ba
+9 -2
View File
@@ -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
}