1
0

fix: use the default config dirs provider

This commit is contained in:
2023-05-21 20:31:47 +00:00
parent ba03d4a049
commit 31b0945a15
5 changed files with 16 additions and 62 deletions

View File

@ -12,7 +12,7 @@ import (
"os"
"os/exec"
"os/signal"
"os/user"
"path/filepath"
"regexp"
"runtime"
"strings"
@ -326,16 +326,10 @@ func findInitrdFile(files []os.FileInfo, kname string) (name string, err error)
}
func GenRootfsImage(d container.Image, download bool) (rootfs string, err error) {
usr, err := user.Current()
if err != nil {
return
}
imagesPath := config.Dir("images")
imageFile := d.Name + ".img"
imagesPath := usr.HomeDir + "/.out-of-tree/images/"
os.MkdirAll(imagesPath, os.ModePerm)
rootfs = imagesPath + imageFile
rootfs = filepath.Join(imagesPath, imageFile)
if !fs.PathExists(rootfs) {
if download {
log.Info().Msgf("%v not available, start download", imageFile)
@ -395,13 +389,7 @@ func UpdateKernelsCfg(host, download bool) (err error) {
buf = append([]byte("# Autogenerated\n# DO NOT EDIT\n\n"), buf...)
usr, err := user.Current()
if err != nil {
return
}
// TODO move all cfg path values to one provider
kernelsCfgPath := usr.HomeDir + "/.out-of-tree/kernels.toml"
kernelsCfgPath := config.File("kernels.toml")
err = ioutil.WriteFile(kernelsCfgPath, buf, 0644)
if err != nil {
return