2019-03-26 08:29:15 -04:00
|
|
|
package yandex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/c2h5oh/datasize"
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2020-11-19 14:54:31 -05:00
|
|
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
2019-03-26 08:29:15 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func stepHaltWithError(state multistep.StateBag, err error) multistep.StepAction {
|
2020-11-19 14:54:31 -05:00
|
|
|
ui := state.Get("ui").(packersdk.Ui)
|
2019-03-26 08:29:15 -04:00
|
|
|
state.Put("error", err)
|
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
func toGigabytes(bytesCount int64) int {
|
|
|
|
return int((datasize.ByteSize(bytesCount) * datasize.B).GBytes())
|
|
|
|
}
|
|
|
|
|
|
|
|
func toBytes(gigabytesCount int) int64 {
|
|
|
|
return int64((datasize.ByteSize(gigabytesCount) * datasize.GB).Bytes())
|
|
|
|
}
|