packer-cn/builder/hyperone/step_post_mount_commands.go

38 lines
930 B
Go
Raw Normal View History

2019-01-28 06:30:15 -05:00
package hyperone
import (
"context"
2020-11-17 19:31:03 -05:00
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
2019-01-28 06:30:15 -05:00
)
type postMountCommandsData struct {
Device string
MountPath string
}
type stepPostMountCommands struct{}
func (s *stepPostMountCommands) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
2019-01-28 06:30:15 -05:00
config := state.Get("config").(*Config)
ui := state.Get("ui").(packersdk.Ui)
2019-01-28 06:30:15 -05:00
device := state.Get("device").(string)
ictx := config.ctx
ictx.Data = &postMountCommandsData{
2019-01-28 06:30:15 -05:00
Device: device,
MountPath: config.ChrootMountPath,
}
ui.Say("Running post-mount commands...")
if err := runCommands(config.PostMountCommands, ictx, state); err != nil {
2019-01-28 06:30:15 -05:00
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (s *stepPostMountCommands) Cleanup(state multistep.StateBag) {}