From 050f809a1cedb6bf7decb9ba739973be09866466 Mon Sep 17 00:00:00 2001 From: Ladar Levison Date: Mon, 17 Dec 2018 22:04:43 -0600 Subject: [PATCH] Add changes var to docker driver import func. --- builder/docker/driver_docker.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/builder/docker/driver_docker.go b/builder/docker/driver_docker.go index 50a2b9920..c052131f8 100644 --- a/builder/docker/driver_docker.go +++ b/builder/docker/driver_docker.go @@ -97,16 +97,26 @@ func (d *DockerDriver) Export(id string, dst io.Writer) error { return nil } -func (d *DockerDriver) Import(path string, repo string) (string, error) { +func (d *DockerDriver) Import(path string, changes []string, repo string) (string, error) { var stdout, stderr bytes.Buffer - cmd := exec.Command("docker", "import", "-", repo) cmd.Stdout = &stdout cmd.Stderr = &stderr stdin, err := cmd.StdinPipe() - if err != nil { + + if err != nil { return "", err } + args := []string{"import"} + + for _, change := range changes { + args = append(args, "--change", change) + } + + args = append(args, "-") + args = append(args, repo) + cmd := exec.Command("docker", args...) + // There should be only one artifact of the Docker builder file, err := os.Open(path) if err != nil { @@ -114,6 +124,8 @@ func (d *DockerDriver) Import(path string, repo string) (string, error) { } defer file.Close() + log.Printf("Importing container with args: %v", args) + if err := cmd.Start(); err != nil { return "", err }