feat: mount container volumes based on kernel info
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								pew.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pew.go
									
									
									
									
									
								
							@@ -270,7 +270,7 @@ func build(flog zerolog.Logger, tmp string, ka config.Artifact,
 | 
			
		||||
 | 
			
		||||
	if ki.ContainerName != "" {
 | 
			
		||||
		var c container.Container
 | 
			
		||||
		c, err = container.New(ki.ContainerName, dockerTimeout)
 | 
			
		||||
		c, err = container.NewFromKernelInfo(ki, dockerTimeout)
 | 
			
		||||
		c.Log = flog
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal().Err(err).Msg("container creation failure")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user