Add changes var to docker driver import func.

This commit is contained in:
Ladar Levison 2018-12-17 22:04:43 -06:00
parent a734aa2255
commit 050f809a1c
1 changed files with 15 additions and 3 deletions

View File

@ -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
}