2016-10-31 16:44:41 -05:00
|
|
|
package ebsvolume
|
|
|
|
|
|
|
|
|
|
import (
|
2017-04-04 13:39:01 -07:00
|
|
|
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
|
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2016-10-31 16:44:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type BlockDevice struct {
|
|
|
|
|
awscommon.BlockDevice `mapstructure:"-,squash"`
|
2018-02-02 20:16:23 -08:00
|
|
|
Tags awscommon.TagMap `mapstructure:"tags"`
|
2016-10-31 16:44:41 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-26 21:10:25 +01:00
|
|
|
func commonBlockDevices(mappings []BlockDevice, ctx *interpolate.Context) (awscommon.BlockDevices, error) {
|
2016-10-31 16:44:41 -05:00
|
|
|
result := make([]awscommon.BlockDevice, len(mappings))
|
2017-01-26 21:10:25 +01:00
|
|
|
|
2016-10-31 16:44:41 -05:00
|
|
|
for i, mapping := range mappings {
|
2017-01-26 21:10:25 +01:00
|
|
|
interpolateBlockDev, err := interpolate.RenderInterface(&mapping.BlockDevice, ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return awscommon.BlockDevices{}, err
|
|
|
|
|
}
|
|
|
|
|
result[i] = *interpolateBlockDev.(*awscommon.BlockDevice)
|
2016-10-31 16:44:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return awscommon.BlockDevices{
|
|
|
|
|
LaunchBlockDevices: awscommon.LaunchBlockDevices{
|
|
|
|
|
LaunchMappings: result,
|
|
|
|
|
},
|
2017-01-26 21:10:25 +01:00
|
|
|
}, nil
|
2016-10-31 16:44:41 -05:00
|
|
|
}
|