Fixed cmd order for docker driver. Added config to post proc.

pull/7127/head
Ladar Levison 7 years ago
parent 10095678c8
commit 6ac5971288

@ -99,13 +99,6 @@ func (d *DockerDriver) Export(id string, dst io.Writer) error {
func (d *DockerDriver) Import(path string, changes []string, repo string) (string, error) {
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
stdin, err := cmd.StdinPipe()
if err != nil {
return "", err
}
args := []string{"import"}
@ -115,7 +108,15 @@ func (d *DockerDriver) Import(path string, changes []string, repo string) (strin
args = append(args, "-")
args = append(args, repo)
cmd := exec.Command("docker", args...)
cmd.Stdout = &stdout
cmd.Stderr = &stderr
stdin, err := cmd.StdinPipe()
if err != nil {
return "", err
}
// There should be only one artifact of the Docker builder
file, err := os.Open(path)
@ -124,7 +125,7 @@ func (d *DockerDriver) Import(path string, changes []string, repo string) (strin
}
defer file.Close()
log.Printf("Importing container with args: %v", args)
log.Printf("Importing tarball with args: %v", args)
if err := cmd.Start(); err != nil {
return "", err

@ -18,6 +18,7 @@ type Config struct {
Repository string `mapstructure:"repository"`
Tag string `mapstructure:"tag"`
Changes []string
ctx interpolate.Context
}
@ -62,7 +63,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
ui.Message("Importing image: " + artifact.Id())
ui.Message("Repository: " + importRepo)
id, err := driver.Import(artifact.Files()[0], importRepo)
id, err := driver.Import(artifact.Files()[0], p.config.Changes, importRepo)
if err != nil {
return nil, false, err
}

Loading…
Cancel
Save