packer-cn/builder/yandex/util.go

23 lines
580 B
Go
Raw Normal View History

2019-03-26 08:29:15 -04:00
package yandex
import (
"github.com/c2h5oh/datasize"
"github.com/hashicorp/packer/packer"
2020-11-17 19:31:03 -05:00
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
2019-03-26 08:29:15 -04:00
)
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())
}