1
0

feat: support changing dotdir

This commit is contained in:
dump_stack() 2023-05-13 15:45:21 +00:00
parent 804b6b56ba
commit 9d1bbcc288
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -7,7 +7,6 @@ package config
import ( import (
"errors" "errors"
"os" "os"
"os/user"
"time" "time"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
@ -21,6 +20,9 @@ type DockerCommand struct {
} }
type OutOfTree struct { type OutOfTree struct {
// Directory for all files if not explicitly specified
Directory string
Kernels string Kernels string
UserKernels string UserKernels string
@ -77,21 +79,20 @@ func ReadOutOfTreeConf(path string) (c OutOfTree, err error) {
err = nil err = nil
} }
usr, err := user.Current() if c.Directory != "" {
if err != nil { Directory = c.Directory
return
} }
if c.Kernels == "" { if c.Kernels == "" {
c.Kernels = usr.HomeDir + "/.out-of-tree/kernels.toml" c.Kernels = File("kernels.toml")
} }
if c.UserKernels == "" { if c.UserKernels == "" {
c.UserKernels = usr.HomeDir + "/.out-of-tree/kernels.user.toml" c.Kernels = File("kernels.user.toml")
} }
if c.Database == "" { if c.Database == "" {
c.Database = usr.HomeDir + "/.out-of-tree/db.sqlite" c.Kernels = File("db.sqlite")
} }
if c.Qemu.Timeout.Duration == 0 { if c.Qemu.Timeout.Duration == 0 {