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

builder/amazon/chroot: process MountPath template

parent 8d5f404f
...@@ -8,8 +8,14 @@ import ( ...@@ -8,8 +8,14 @@ import (
"log" "log"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"text/template"
) )
type mountPathData struct {
Device string
}
// StepMountDevice mounts the attached device. // StepMountDevice mounts the attached device.
// //
// Produces: // Produces:
...@@ -23,7 +29,13 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction ...@@ -23,7 +29,13 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
device := state["device"].(string) 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) log.Printf("Mount path: %s", mountPath)
if err := os.MkdirAll(mountPath, 0755); err != nil { if err := os.MkdirAll(mountPath, 0755); err != nil {
...@@ -46,6 +58,9 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction ...@@ -46,6 +58,9 @@ func (s *StepMountDevice) Run(state map[string]interface{}) multistep.StepAction
return multistep.ActionHalt return multistep.ActionHalt
} }
// Set the mount path so we remember to unmount it later
s.mountPath = mountPath
return multistep.ActionContinue 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