containerkit: layer manipulator overlay poc

A light weight overlay implementation that emits working mounts is
demonstrated. One can prepare and commit changes. The diffs are
correctly held on disk.

The next step from here is to implement the changes methods and ensure
that we can work with the docker registry API.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2016-09-26 21:35:34 -07:00
parent 34b630c861
commit c2da97c4d1
3 changed files with 267 additions and 6 deletions

View file

@ -1,5 +1,11 @@
package containerkit
import (
"os"
"os/exec"
"strings"
)
// Mount is the lingua franca of the containerkit. A mount represents a
// serialized mount syscall. Components either emit or consume mounts.
type Mount struct {
@ -17,3 +23,28 @@ type Mount struct {
// these are platform specific.
Options []string
}
// MountCommand converts the provided mount into a CLI arguments that can be used to mount the
func MountCommand(m Mount) []string {
return []string{
"mount",
"-t", strings.ToLower(m.Type),
m.Source,
m.Target,
"-o", strings.Join(m.Options, ","),
}
}
func MountAll(mounts ...Mount) error {
for _, mount := range mounts {
cmd := exec.Command("mount", MountCommand(mount)[1:]...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return err
}
}
return nil
}