9ec8b67392
* Add golangci-lint as linting tool * Disable failing staticchecks to start; GitHub issue to handle coming soon * Run `goimports -w` to repair all source files that have improperly formatted imports * makefile: Add ci-lint target to run on travis This change adds a new make target for running golangci-lint on newly added Go files only. This target is expected to run during Packer ci builds. * .github/contributing: Add code linting instructions * travis: Update job configuration to run parallel builds
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package lxc
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/hashicorp/packer/common"
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
"github.com/hashicorp/packer/packer"
|
|
)
|
|
|
|
// StepProvision provisions the instance within a chroot.
|
|
type StepProvision struct{}
|
|
|
|
func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
|
hook := state.Get("hook").(packer.Hook)
|
|
config := state.Get("config").(*Config)
|
|
mountPath := state.Get("mount_path").(string)
|
|
ui := state.Get("ui").(packer.Ui)
|
|
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
|
|
|
|
// Create our communicator
|
|
comm := &LxcAttachCommunicator{
|
|
ContainerName: config.ContainerName,
|
|
AttachOptions: config.AttachOptions,
|
|
RootFs: mountPath,
|
|
CmdWrapper: wrappedCommand,
|
|
}
|
|
|
|
// Loads hook data from builder's state, if it has been set.
|
|
hookData := common.PopulateProvisionHookData(state)
|
|
|
|
// Update state generated_data with complete hookData
|
|
// to make them accessible by post-processors
|
|
state.Put("generated_data", hookData)
|
|
|
|
// Provision
|
|
log.Println("Running the provision hook")
|
|
if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil {
|
|
state.Put("error", err)
|
|
return multistep.ActionHalt
|
|
}
|
|
|
|
return multistep.ActionContinue
|
|
}
|
|
|
|
func (s *StepProvision) Cleanup(state multistep.StateBag) {}
|