1
0

feat: mount container volumes based on kernel info

This commit is contained in:
2023-05-14 21:39:41 +00:00
parent 42be5161d8
commit de5ebd6455
2 changed files with 20 additions and 1 deletions

View File

@ -11,6 +11,8 @@ import (
"os"
"os/exec"
"os/user"
"path"
"path/filepath"
"regexp"
"strings"
"time"
@ -117,6 +119,23 @@ func New(name string, timeout time.Duration) (c Container, err error) {
return
}
func NewFromKernelInfo(ki config.KernelInfo, timeout time.Duration) (
c Container, err error) {
c.name = ki.ContainerName
c.timeout = timeout
c.Log = log.With().
Str("container", c.name).
Logger()
c.Volumes.LibModules = path.Dir(ki.ModulesPath)
c.Volumes.Boot = path.Dir(ki.KernelPath)
c.Volumes.UsrSrc = filepath.Join(path.Dir(ki.KernelPath), "../usr/src")
return
}
func (c Container) Build(imagePath string) (output string, err error) {
args := []string{"build"}
args = append(args, "-t", c.name, imagePath)