2019-02-22 10:50:46 -05:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
|
|
"github.com/hashicorp/packer/packer"
|
2020-09-30 11:38:31 -04:00
|
|
|
"github.com/outscale/osc-sdk-go/osc"
|
2019-02-22 10:50:46 -05:00
|
|
|
)
|
|
|
|
|
2019-03-05 12:58:59 -05:00
|
|
|
// StepCheckRootDevice makes sure the root device on the OMI is BSU-backed.
|
2019-02-22 10:50:46 -05:00
|
|
|
type StepCheckRootDevice struct{}
|
|
|
|
|
|
|
|
func (s *StepCheckRootDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
2020-09-30 11:38:31 -04:00
|
|
|
image := state.Get("source_image").(osc.Image)
|
2019-02-22 10:50:46 -05:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2019-03-05 12:58:59 -05:00
|
|
|
ui.Say("Checking the root device on source OMI...")
|
2019-02-22 10:50:46 -05:00
|
|
|
|
2019-03-05 12:58:59 -05:00
|
|
|
// It must be BSU-backed otherwise the build won't work
|
2019-02-22 10:50:46 -05:00
|
|
|
if image.RootDeviceType != "ebs" {
|
2019-03-05 12:58:59 -05:00
|
|
|
err := fmt.Errorf("The root device of the source OMI must be BSU-backed.")
|
2019-02-22 10:50:46 -05:00
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepCheckRootDevice) Cleanup(multistep.StateBag) {}
|