packer-cn/builder/yandex/util.go

23 lines
569 B
Go

package yandex
import (
"github.com/c2h5oh/datasize"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
)
func stepHaltWithError(state multistep.StateBag, err error) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
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())
}