Merge pull request #8269 from paulmey/paulmey/generalize-chroot

[amazon/chroot] Move common/generic chroot builder steps to common directory
This commit is contained in:
Megan Marsh 2019-10-24 14:32:01 -07:00 committed by GitHub
commit a783a09ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 79 additions and 51 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
awscommon "github.com/hashicorp/packer/builder/amazon/common" awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/chroot"
"github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
@ -173,10 +174,6 @@ func (c *Config) GetContext() interpolate.Context {
return c.ctx return c.ctx
} }
type interpolateContextProvider interface {
GetContext() interpolate.Context
}
type wrappedCommandTemplate struct { type wrappedCommandTemplate struct {
Command string Command string
} }
@ -356,7 +353,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
state.Put("awsSession", session) state.Put("awsSession", session)
state.Put("hook", hook) state.Put("hook", hook)
state.Put("ui", ui) state.Put("ui", ui)
state.Put("wrappedCommand", CommandWrapper(wrappedCommand)) state.Put("wrappedCommand", common.CommandWrapper(wrappedCommand))
// Build the steps // Build the steps
steps := []multistep.Step{ steps := []multistep.Step{
@ -391,24 +388,24 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
}, },
&StepAttachVolume{}, &StepAttachVolume{},
&StepEarlyUnflock{}, &StepEarlyUnflock{},
&StepPreMountCommands{ &chroot.StepPreMountCommands{
Commands: b.config.PreMountCommands, Commands: b.config.PreMountCommands,
}, },
&StepMountDevice{ &StepMountDevice{
MountOptions: b.config.MountOptions, MountOptions: b.config.MountOptions,
MountPartition: b.config.MountPartition, MountPartition: b.config.MountPartition,
}, },
&StepPostMountCommands{ &chroot.StepPostMountCommands{
Commands: b.config.PostMountCommands, Commands: b.config.PostMountCommands,
}, },
&StepMountExtra{ &chroot.StepMountExtra{
ChrootMounts: b.config.ChrootMounts, ChrootMounts: b.config.ChrootMounts,
}, },
&StepCopyFiles{ &chroot.StepCopyFiles{
Files: b.config.CopyFiles, Files: b.config.CopyFiles,
}, },
&StepChrootProvision{}, &chroot.StepChrootProvision{},
&StepEarlyCleanup{}, &chroot.StepEarlyCleanup{},
&StepSnapshot{}, &StepSnapshot{},
&awscommon.StepDeregisterAMI{ &awscommon.StepDeregisterAMI{
AccessConfig: &b.config.AccessConfig, AccessConfig: &b.config.AccessConfig,

View File

@ -6,6 +6,8 @@ import (
"os" "os"
"runtime" "runtime"
"testing" "testing"
"github.com/hashicorp/packer/common"
) )
func TestCopyFile(t *testing.T) { func TestCopyFile(t *testing.T) {
@ -26,7 +28,7 @@ func TestCopyFile(t *testing.T) {
} }
first.Sync() first.Sync()
cmd := ShellCommand(fmt.Sprintf("cp %s %s", first.Name(), newName)) cmd := common.ShellCommand(fmt.Sprintf("cp %s %s", first.Name(), newName))
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
t.Fatalf("Couldn't copy file") t.Fatalf("Couldn't copy file")
} }

View File

@ -1,11 +1,15 @@
package chroot package chroot
import "testing" import (
"testing"
"github.com/hashicorp/packer/common/chroot"
)
func TestAttachVolumeCleanupFunc_ImplementsCleanupFunc(t *testing.T) { func TestAttachVolumeCleanupFunc_ImplementsCleanupFunc(t *testing.T) {
var raw interface{} var raw interface{}
raw = new(StepAttachVolume) raw = new(StepAttachVolume)
if _, ok := raw.(Cleanup); !ok { if _, ok := raw.(chroot.Cleanup); !ok {
t.Fatalf("cleanup func should be a CleanupFunc") t.Fatalf("cleanup func should be a CleanupFunc")
} }
} }

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/hashicorp/packer/common/chroot"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -13,7 +14,7 @@ import (
type StepEarlyUnflock struct{} type StepEarlyUnflock struct{}
func (s *StepEarlyUnflock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { func (s *StepEarlyUnflock) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
cleanup := state.Get("flock_cleanup").(Cleanup) cleanup := state.Get("flock_cleanup").(chroot.Cleanup)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
log.Println("Unlocking file lock...") log.Println("Unlocking file lock...")

View File

@ -1,11 +1,15 @@
package chroot package chroot
import "testing" import (
"testing"
"github.com/hashicorp/packer/common/chroot"
)
func TestFlockCleanupFunc_ImplementsCleanupFunc(t *testing.T) { func TestFlockCleanupFunc_ImplementsCleanupFunc(t *testing.T) {
var raw interface{} var raw interface{}
raw = new(StepFlock) raw = new(StepFlock)
if _, ok := raw.(Cleanup); !ok { if _, ok := raw.(chroot.Cleanup); !ok {
t.Fatalf("cleanup func should be a CleanupFunc") t.Fatalf("cleanup func should be a CleanupFunc")
} }
} }

View File

@ -10,6 +10,7 @@ import (
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
@ -39,7 +40,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul
// customizable device path for mounting NVME block devices on c5 and m5 HVM // customizable device path for mounting NVME block devices on c5 and m5 HVM
device = config.NVMEDevicePath device = config.NVMEDevicePath
} }
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
var virtualizationType string var virtualizationType string
if config.FromScratch || config.AMIVirtType != "" { if config.FromScratch || config.AMIVirtType != "" {
@ -104,7 +105,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul
return multistep.ActionHalt return multistep.ActionHalt
} }
log.Printf("[DEBUG] (step mount) mount command is %s", mountCommand) log.Printf("[DEBUG] (step mount) mount command is %s", mountCommand)
cmd := ShellCommand(mountCommand) cmd := common.ShellCommand(mountCommand)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
err := fmt.Errorf( err := fmt.Errorf(
@ -135,7 +136,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error {
} }
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
ui.Say("Unmounting the root device...") ui.Say("Unmounting the root device...")
unmountCommand, err := wrappedCommand(fmt.Sprintf("umount %s", s.mountPath)) unmountCommand, err := wrappedCommand(fmt.Sprintf("umount %s", s.mountPath))
@ -143,7 +144,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error {
return fmt.Errorf("Error creating unmount command: %s", err) return fmt.Errorf("Error creating unmount command: %s", err)
} }
cmd := ShellCommand(unmountCommand) cmd := common.ShellCommand(unmountCommand)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return fmt.Errorf("Error unmounting root device: %s", err) return fmt.Errorf("Error unmounting root device: %s", err)
} }

View File

@ -1,11 +1,15 @@
package chroot package chroot
import "testing" import (
"testing"
"github.com/hashicorp/packer/common/chroot"
)
func TestMountDeviceCleanupFunc_ImplementsCleanupFunc(t *testing.T) { func TestMountDeviceCleanupFunc_ImplementsCleanupFunc(t *testing.T) {
var raw interface{} var raw interface{}
raw = new(StepMountDevice) raw = new(StepMountDevice)
if _, ok := raw.(Cleanup); !ok { if _, ok := raw.(chroot.Cleanup); !ok {
t.Fatalf("cleanup func should be a CleanupFunc") t.Fatalf("cleanup func should be a CleanupFunc")
} }
} }

View File

@ -14,10 +14,10 @@ import (
"runtime" "runtime"
"strings" "strings"
"github.com/hashicorp/packer/builder/amazon/chroot"
azcommon "github.com/hashicorp/packer/builder/azure/common" azcommon "github.com/hashicorp/packer/builder/azure/common"
"github.com/hashicorp/packer/builder/azure/common/client" "github.com/hashicorp/packer/builder/azure/common/client"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/chroot"
"github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
@ -317,7 +317,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
state.Put("hook", hook) state.Put("hook", hook)
state.Put("ui", ui) state.Put("ui", ui)
state.Put("azureclient", azcli) state.Put("azureclient", azcli)
state.Put("wrappedCommand", chroot.CommandWrapper(wrappedCommand)) state.Put("wrappedCommand", common.CommandWrapper(wrappedCommand))
info, err := azcli.MetadataClient().GetComputeInfo() info, err := azcli.MetadataClient().GetComputeInfo()
if err != nil { if err != nil {

View File

@ -6,14 +6,15 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/amazon/chroot"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
) )
var _ multistep.Step = &StepMountDevice{} var _ multistep.Step = &StepMountDevice{}
@ -30,7 +31,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
device := state.Get("device").(string) device := state.Get("device").(string)
config := state.Get("config").(*Config) config := state.Get("config").(*Config)
wrappedCommand := state.Get("wrappedCommand").(chroot.CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
ictx := config.ctx ictx := config.ctx
@ -83,7 +84,7 @@ func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) mul
return multistep.ActionHalt return multistep.ActionHalt
} }
log.Printf("[DEBUG] (step mount) mount command is %s", mountCommand) log.Printf("[DEBUG] (step mount) mount command is %s", mountCommand)
cmd := chroot.ShellCommand(mountCommand) cmd := common.ShellCommand(mountCommand)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
err := fmt.Errorf( err := fmt.Errorf(
@ -114,7 +115,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error {
} }
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(chroot.CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
ui.Say("Unmounting the root device...") ui.Say("Unmounting the root device...")
unmountCommand, err := wrappedCommand(fmt.Sprintf("umount %s", s.mountPath)) unmountCommand, err := wrappedCommand(fmt.Sprintf("umount %s", s.mountPath))
@ -122,7 +123,7 @@ func (s *StepMountDevice) CleanupFunc(state multistep.StateBag) error {
return fmt.Errorf("error creating unmount command: %s", err) return fmt.Errorf("error creating unmount command: %s", err)
} }
cmd := chroot.ShellCommand(unmountCommand) cmd := common.ShellCommand(unmountCommand)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return fmt.Errorf("error unmounting root device: %s", err) return fmt.Errorf("error unmounting root device: %s", err)
} }

View File

@ -13,6 +13,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer/tmp" "github.com/hashicorp/packer/packer/tmp"
) )
@ -21,7 +22,7 @@ import (
// commands locally but within a chroot. // commands locally but within a chroot.
type Communicator struct { type Communicator struct {
Chroot string Chroot string
CmdWrapper CommandWrapper CmdWrapper common.CommandWrapper
} }
func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error {
@ -33,7 +34,7 @@ func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error {
return err return err
} }
localCmd := ShellCommand(command) localCmd := common.ShellCommand(command)
localCmd.Stdin = cmd.Stdin localCmd.Stdin = cmd.Stdin
localCmd.Stdout = cmd.Stdout localCmd.Stdout = cmd.Stdout
localCmd.Stderr = cmd.Stderr localCmd.Stderr = cmd.Stderr
@ -83,7 +84,7 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error {
return err return err
} }
return ShellCommand(cpCmd).Run() return common.ShellCommand(cpCmd).Run()
} }
func (c *Communicator) UploadDir(dst string, src string, exclude []string) error { func (c *Communicator) UploadDir(dst string, src string, exclude []string) error {
@ -105,7 +106,7 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error
} }
var stderr bytes.Buffer var stderr bytes.Buffer
cmd := ShellCommand(cpCmd) cmd := common.ShellCommand(cpCmd)
cmd.Env = append(cmd.Env, "LANG=C") cmd.Env = append(cmd.Env, "LANG=C")
cmd.Env = append(cmd.Env, os.Environ()...) cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Stderr = &stderr cmd.Stderr = &stderr

View File

@ -0,0 +1,7 @@
package chroot
import "github.com/hashicorp/packer/template/interpolate"
type interpolateContextProvider interface {
GetContext() interpolate.Context
}

View File

@ -4,12 +4,13 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/common"
sl "github.com/hashicorp/packer/common/shell-local" sl "github.com/hashicorp/packer/common/shell-local"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx interpolate.Context, ui packer.Ui) error { func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, ictx interpolate.Context, ui packer.Ui) error {
ctx := context.TODO() ctx := context.TODO()
for _, rawCmd := range commands { for _, rawCmd := range commands {
intCmd, err := interpolate.Render(rawCmd, &ictx) intCmd, err := interpolate.Render(rawCmd, &ictx)

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"log" "log"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -16,7 +17,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag)
hook := state.Get("hook").(packer.Hook) hook := state.Get("hook").(packer.Hook)
mountPath := state.Get("mount_path").(string) mountPath := state.Get("mount_path").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
// Create our communicator // Create our communicator
comm := &Communicator{ comm := &Communicator{

View File

@ -7,6 +7,7 @@ import (
"log" "log"
"path/filepath" "path/filepath"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -24,7 +25,7 @@ type StepCopyFiles struct {
func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
mountPath := state.Get("mount_path").(string) mountPath := state.Get("mount_path").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
stderr := new(bytes.Buffer) stderr := new(bytes.Buffer)
s.files = make([]string, 0, len(s.Files)) s.files = make([]string, 0, len(s.Files))
@ -44,7 +45,7 @@ func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multi
} }
stderr.Reset() stderr.Reset()
cmd := ShellCommand(cmdText) cmd := common.ShellCommand(cmdText)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
err := fmt.Errorf( err := fmt.Errorf(
@ -70,7 +71,7 @@ func (s *StepCopyFiles) Cleanup(state multistep.StateBag) {
} }
func (s *StepCopyFiles) CleanupFunc(state multistep.StateBag) error { func (s *StepCopyFiles) CleanupFunc(state multistep.StateBag) error {
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
if s.files != nil { if s.files != nil {
for _, file := range s.files { for _, file := range s.files {
log.Printf("Removing: %s", file) log.Printf("Removing: %s", file)
@ -79,7 +80,7 @@ func (s *StepCopyFiles) CleanupFunc(state multistep.StateBag) error {
return err return err
} }
localCmd := ShellCommand(localCmdText) localCmd := common.ShellCommand(localCmdText)
if err := localCmd.Run(); err != nil { if err := localCmd.Run(); err != nil {
return err return err
} }

View File

@ -8,6 +8,7 @@ import (
"os/exec" "os/exec"
"syscall" "syscall"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -24,7 +25,7 @@ type StepMountExtra struct {
func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
mountPath := state.Get("mount_path").(string) mountPath := state.Get("mount_path").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
s.mounts = make([]string, 0, len(s.ChrootMounts)) s.mounts = make([]string, 0, len(s.ChrootMounts))
@ -58,7 +59,7 @@ func (s *StepMountExtra) Run(ctx context.Context, state multistep.StateBag) mult
return multistep.ActionHalt return multistep.ActionHalt
} }
cmd := ShellCommand(mountCommand) cmd := common.ShellCommand(mountCommand)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
err := fmt.Errorf( err := fmt.Errorf(
@ -89,7 +90,7 @@ func (s *StepMountExtra) CleanupFunc(state multistep.StateBag) error {
return nil return nil
} }
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
for len(s.mounts) > 0 { for len(s.mounts) > 0 {
var path string var path string
lastIndex := len(s.mounts) - 1 lastIndex := len(s.mounts) - 1
@ -103,7 +104,7 @@ func (s *StepMountExtra) CleanupFunc(state multistep.StateBag) error {
// Before attempting to unmount, // Before attempting to unmount,
// check to see if path is already unmounted // check to see if path is already unmounted
stderr := new(bytes.Buffer) stderr := new(bytes.Buffer)
cmd := ShellCommand(grepCommand) cmd := common.ShellCommand(grepCommand)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok { if exitError, ok := err.(*exec.ExitError); ok {
@ -124,7 +125,7 @@ func (s *StepMountExtra) CleanupFunc(state multistep.StateBag) error {
} }
stderr = new(bytes.Buffer) stderr = new(bytes.Buffer)
cmd = ShellCommand(unmountCommand) cmd = common.ShellCommand(unmountCommand)
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return fmt.Errorf( return fmt.Errorf(

View File

@ -3,6 +3,7 @@ package chroot
import ( import (
"context" "context"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -23,7 +24,7 @@ func (s *StepPostMountCommands) Run(ctx context.Context, state multistep.StateBa
device := state.Get("device").(string) device := state.Get("device").(string)
mountPath := state.Get("mount_path").(string) mountPath := state.Get("mount_path").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
if len(s.Commands) == 0 { if len(s.Commands) == 0 {
return multistep.ActionContinue return multistep.ActionContinue

View File

@ -3,6 +3,7 @@ package chroot
import ( import (
"context" "context"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )
@ -20,7 +21,7 @@ func (s *StepPreMountCommands) Run(ctx context.Context, state multistep.StateBag
config := state.Get("config").(interpolateContextProvider) config := state.Get("config").(interpolateContextProvider)
device := state.Get("device").(string) device := state.Get("device").(string)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper)
if len(s.Commands) == 0 { if len(s.Commands) == 0 {
return multistep.ActionContinue return multistep.ActionContinue

View File

@ -1,4 +1,4 @@
package chroot package common
import ( import (
"os/exec" "os/exec"