Commit 618e1b16 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/chroot: process MountPath template

parent 8d5f404f
......@@ -8,8 +8,14 @@ import (
"log"
"os"
"os/exec"
"path/filepath"
"text/template"
)
type mountPathData struct {
Device string
}
// StepMountDevice mounts the attached device.
//
// Produces:
......@@ -23,7 +29,13 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction
ui := state["ui"].(packer.Ui)
device := state["device"].(string)
mountPath := config.MountPath
mountPathRaw := new(bytes.Buffer)
t := template.Must(template.New("mountPath").Parse(config.MountPath))
t.Execute(mountPathRaw, &mountPathData{
Device: filepath.Basename(device),
})
mountPath := mountPathRaw.String()
log.Printf("Mount path: %s", mountPath)
if err := os.MkdirAll(mountPath, 0755); err != nil {
......@@ -46,6 +58,9 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction
return multistep.ActionHalt
}
// Set the mount path so we remember to unmount it later
s.mountPath = mountPath
return multistep.ActionContinue
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment