fixing up types.
This commit is contained in:
parent
ac496a63dc
commit
d2f9ba0d11
|
@ -82,3 +82,14 @@ func TestBuilderPrepare_SourceAmi(t *testing.T) {
|
|||
t.Errorf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_CommandWrapper(t *testing.T) {
|
||||
b := &Builder{}
|
||||
config := testConfig()
|
||||
|
||||
config["command_wrapper"] = "echo hi; {{.Command}}"
|
||||
err := b.Prepare(config)
|
||||
if err != nil {
|
||||
t.Errorf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ func TestCopyFile(t *testing.T) {
|
|||
if _, err = first.WriteString(payload); err != nil {
|
||||
t.Fatalf("Couldn't write payload to first file.")
|
||||
}
|
||||
first.Sync()
|
||||
|
||||
if err := copySingle(newName, first.Name(), "cp"); err != nil {
|
||||
cmd := ShellCommand(fmt.Sprintf("cp %s %s", first.Name(), newName))
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("Couldn't copy file")
|
||||
}
|
||||
defer os.Remove(newName)
|
||||
|
|
|
@ -13,7 +13,7 @@ type StepChrootProvision struct {
|
|||
}
|
||||
|
||||
type WrappedCommandTemplate struct {
|
||||
command string
|
||||
Command string
|
||||
}
|
||||
|
||||
func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction {
|
||||
|
@ -26,7 +26,7 @@ func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction
|
|||
}
|
||||
wrappedCommand := func(command string) *exec.Cmd {
|
||||
wrapped, err := config.tpl.Process(config.CommandWrapper, &WrappedCommandTemplate{
|
||||
command: command,
|
||||
Command: command,
|
||||
})
|
||||
if err != nil {
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -60,7 +60,6 @@ func (s *StepCopyFiles) CleanupFunc(state multistep.StateBag) error {
|
|||
for _, file := range s.files {
|
||||
log.Printf("Removing: %s", file)
|
||||
localCmd := wrappedCommand(fmt.Sprintf("rm -f %s", file))
|
||||
log.Println(localCmd.Args)
|
||||
if err := localCmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ui.Say("Mounting the root device...")
|
||||
stderr := new(bytes.Buffer)
|
||||
mountCommand := fmt.Sprintf("mount %s %s", device, mountPath)
|
||||
wrappedCommand := state.Get("wrappedCommand").(Command)
|
||||
wrappedCommand := state.Get("wrappedCommand").(*Command)
|
||||
cmd := wrappedCommand(mountCommand)
|
||||
cmd.Stderr = stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue