1
0

Additional arguments for containers

This commit is contained in:
dump_stack() 2023-04-06 14:30:42 +00:00
parent 87ef1e42b5
commit 3220b9a5ae
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -23,6 +23,8 @@ type container struct {
UsrSrc string UsrSrc string
Boot string Boot string
} }
// Additional arguments
Args []string
} }
func NewContainer(name string, timeout time.Duration) (c container, err error) { func NewContainer(name string, timeout time.Duration) (c container, err error) {
@ -62,12 +64,17 @@ func (c container) Build(imagePath string) (output string, err error) {
} }
func (c container) Run(workdir string, command string) (output string, err error) { func (c container) Run(workdir string, command string) (output string, err error) {
cmd := exec.Command("docker", "run", "--rm", var args []string
args = append(args, "run", "--rm")
args = append(args, c.Args...)
args = append(args,
"-v", workdir+":/work", "-v", workdir+":/work",
"-v", c.Volumes.LibModules+":/lib/modules", "-v", c.Volumes.LibModules+":/lib/modules",
"-v", c.Volumes.UsrSrc+":/usr/src", "-v", c.Volumes.UsrSrc+":/usr/src",
"-v", c.Volumes.Boot+":/boot", "-v", c.Volumes.Boot+":/boot")
c.name, "bash", "-c", "cd /work && "+command) args = append(args, c.name, "bash", "-c", "cd /work && "+command)
cmd := exec.Command("docker", args...)
log.Debug().Msgf("%v", cmd) log.Debug().Msgf("%v", cmd)