Move common steps together
This commit is contained in:
parent
e6dfe301ac
commit
3be7d81ce2
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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...")
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package chroot
|
||||||
|
|
||||||
|
import "github.com/hashicorp/packer/template/interpolate"
|
||||||
|
|
||||||
|
type interpolateContextProvider interface {
|
||||||
|
GetContext() interpolate.Context
|
||||||
|
}
|
Loading…
Reference in New Issue