diff options
Diffstat (limited to 'ops/besadii/main.go')
-rw-r--r-- | ops/besadii/main.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 8bb4b34740cd..28695d5214f4 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -23,6 +23,7 @@ import ( "log/syslog" "net/http" "os" + "os/user" "path" "regexp" "strconv" @@ -96,10 +97,24 @@ type reviewInput struct { Tag string `json:"tag"` } +func defaultConfigLocation() (string, error) { + usr, err := user.Current() + if err != nil { + return "", fmt.Errorf("failed to get current user: %w", err) + } + + return path.Join(usr.HomeDir, "besadii.json"), nil +} + func loadConfig() (*config, error) { configPath := os.Getenv("BESADII_CONFIG") + if configPath == "" { - configPath = "/etc/besadii/config.json" + var err error + configPath, err = defaultConfigLocation() + if err != nil { + return nil, fmt.Errorf("failed to get config location: %w", err) + } } configJson, err := ioutil.ReadFile(configPath) |