Compare commits
No commits in common. "a7ecc354a9ae87fe31f7cb39e23973bee5387ade" and "cdfa4804797fafa9272091ebef4559af09623e58" have entirely different histories.
a7ecc354a9
...
cdfa480479
@ -19,7 +19,6 @@ type ContainerCmd struct {
|
|||||||
Filter string `help:"filter by name"`
|
Filter string `help:"filter by name"`
|
||||||
|
|
||||||
List ContainerListCmd `cmd:"" help:"list containers"`
|
List ContainerListCmd `cmd:"" help:"list containers"`
|
||||||
Update ContainerUpdateCmd `cmd:"" help:"update containers"`
|
|
||||||
Save ContainerSaveCmd `cmd:"" help:"save containers"`
|
Save ContainerSaveCmd `cmd:"" help:"save containers"`
|
||||||
Cleanup ContainerCleanupCmd `cmd:"" help:"cleanup containers"`
|
Cleanup ContainerCleanupCmd `cmd:"" help:"cleanup containers"`
|
||||||
}
|
}
|
||||||
@ -48,39 +47,6 @@ func (cmd ContainerListCmd) Run(containerCmd *ContainerCmd) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerUpdateCmd struct{}
|
|
||||||
|
|
||||||
func (cmd ContainerUpdateCmd) Run(g *Globals, containerCmd *ContainerCmd) (err error) {
|
|
||||||
images, err := container.Images()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
container.UseCache = false
|
|
||||||
container.UsePrebuilt = false
|
|
||||||
|
|
||||||
// TODO move from all commands to main command line handler
|
|
||||||
container.Commands = g.Config.Docker.Commands
|
|
||||||
container.Registry = g.Config.Docker.Registry
|
|
||||||
container.Timeout = g.Config.Docker.Timeout.Duration
|
|
||||||
|
|
||||||
for _, img := range images {
|
|
||||||
if containerCmd.Filter != "" {
|
|
||||||
if !strings.Contains(img.Name, containerCmd.Filter) {
|
|
||||||
log.Debug().Msgf("skip %s", img.Name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = img.Distro.Packages()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContainerSaveCmd struct {
|
type ContainerSaveCmd struct {
|
||||||
OutDir string `help:"directory to save containers" default:"./" type:"existingdir"`
|
OutDir string `help:"directory to save containers" default:"./" type:"existingdir"`
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,9 @@ type OutOfTree struct {
|
|||||||
Timeout artifact.Duration
|
Timeout artifact.Duration
|
||||||
Registry string
|
Registry string
|
||||||
|
|
||||||
// Commands that are executed before (prepend) and after (append) the
|
// Commands that will be executed before
|
||||||
// base layer of the Dockerfile.
|
// the base layer of Dockerfile
|
||||||
Commands struct {
|
Commands []distro.Command
|
||||||
Prepend []distro.Command
|
|
||||||
Append []distro.Command
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,7 @@ var Registry = ""
|
|||||||
|
|
||||||
var Timeout time.Duration
|
var Timeout time.Duration
|
||||||
|
|
||||||
// Commands that are executed before (prepend) and after (append) the
|
var Commands []distro.Command
|
||||||
// base layer of the Dockerfile.
|
|
||||||
var Commands struct {
|
|
||||||
Prepend []distro.Command
|
|
||||||
Append []distro.Command
|
|
||||||
}
|
|
||||||
|
|
||||||
var UseCache = true
|
var UseCache = true
|
||||||
|
|
||||||
@ -102,23 +97,13 @@ func Load(localpath string, name string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(Runtime, "docker") {
|
|
||||||
var err2 error
|
|
||||||
cmd = exec.Command(Runtime, "tag", "localhost/"+name, name)
|
cmd = exec.Command(Runtime, "tag", "localhost/"+name, name)
|
||||||
log.Debug().Msgf("%v", cmd)
|
log.Debug().Msgf("%v", cmd)
|
||||||
|
|
||||||
raw, err2 = cmd.CombinedOutput()
|
raw, err = cmd.CombinedOutput()
|
||||||
if err2 != nil {
|
if err != nil {
|
||||||
log.Debug().Err(err2).Msg(string(raw))
|
log.Debug().Err(err).Msg(string(raw))
|
||||||
}
|
return
|
||||||
|
|
||||||
cmd = exec.Command(Runtime, "rmi", "localhost/"+name)
|
|
||||||
log.Debug().Msgf("%v", cmd)
|
|
||||||
|
|
||||||
raw, err2 = cmd.CombinedOutput()
|
|
||||||
if err2 != nil {
|
|
||||||
log.Debug().Err(err2).Msg(string(raw))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -301,15 +286,9 @@ func (c Container) Build(image string, envs, runs []string) (err error) {
|
|||||||
}
|
}
|
||||||
cf += image + "\n"
|
cf += image + "\n"
|
||||||
|
|
||||||
for _, cmd := range Commands.Prepend {
|
for _, c := range Commands {
|
||||||
if cmd.Distro.ID != distro.None && cmd.Distro.ID != c.dist.ID {
|
// TODO check for distro type
|
||||||
continue
|
cf += "RUN " + c.Command + "\n"
|
||||||
}
|
|
||||||
if cmd.Distro.Release != "" && cmd.Distro.Release != c.dist.Release {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
cf += "RUN " + cmd.Command + "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range envs {
|
for _, e := range envs {
|
||||||
@ -320,17 +299,6 @@ func (c Container) Build(image string, envs, runs []string) (err error) {
|
|||||||
cf += "RUN " + c + "\n"
|
cf += "RUN " + c + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range Commands.Append {
|
|
||||||
if cmd.Distro.ID != distro.None && cmd.Distro.ID != c.dist.ID {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if cmd.Distro.Release != "" && cmd.Distro.Release != c.dist.Release {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
cf += "RUN " + cmd.Command + "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
buf, err := os.ReadFile(cfile)
|
buf, err := os.ReadFile(cfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = os.WriteFile(cfile, []byte(cf), os.ModePerm)
|
err = os.WriteFile(cfile, []byte(cf), os.ModePerm)
|
||||||
|
6
main.go
6
main.go
@ -35,13 +35,13 @@ type CLI struct {
|
|||||||
cmd.Globals
|
cmd.Globals
|
||||||
|
|
||||||
Pew cmd.PewCmd `cmd:"" help:"build, run, and test module/exploit"`
|
Pew cmd.PewCmd `cmd:"" help:"build, run, and test module/exploit"`
|
||||||
Kernel cmd.KernelCmd `cmd:"" aliases:"kernels" help:"manipulate kernels"`
|
Kernel cmd.KernelCmd `cmd:"" help:"manipulate kernels"`
|
||||||
Debug cmd.DebugCmd `cmd:"" help:"debug environment"`
|
Debug cmd.DebugCmd `cmd:"" help:"debug environment"`
|
||||||
Log cmd.LogCmd `cmd:"" help:"query logs"`
|
Log cmd.LogCmd `cmd:"" help:"query logs"`
|
||||||
Pack cmd.PackCmd `cmd:"" help:"exploit pack test"`
|
Pack cmd.PackCmd `cmd:"" help:"exploit pack test"`
|
||||||
Gen cmd.GenCmd `cmd:"" help:"generate .out-of-tree.toml skeleton"`
|
Gen cmd.GenCmd `cmd:"" help:"generate .out-of-tree.toml skeleton"`
|
||||||
Image cmd.ImageCmd `cmd:"" aliases:"images" help:"manage images"`
|
Image cmd.ImageCmd `cmd:"" help:"manage images"`
|
||||||
Container cmd.ContainerCmd `cmd:"" aliases:"containers" help:"manage containers"`
|
Container cmd.ContainerCmd `cmd:"" help:"manage containers"`
|
||||||
Distro cmd.DistroCmd `cmd:"" help:"distro-related helpers"`
|
Distro cmd.DistroCmd `cmd:"" help:"distro-related helpers"`
|
||||||
|
|
||||||
Daemon cmd.DaemonCmd `cmd:"" help:"run daemon"`
|
Daemon cmd.DaemonCmd `cmd:"" help:"run daemon"`
|
||||||
|
Loading…
Reference in New Issue
Block a user