aws block devices mapping: BlockDevices.Build -> BuildEC2BlockDeviceMappings()

This commit is contained in:
Adrien Delorme 2019-06-18 12:44:24 +02:00
parent ff2e0298ba
commit c696878d2e
8 changed files with 11 additions and 11 deletions

View File

@ -82,7 +82,7 @@ func buildBaseRegisterOpts(config *Config, sourceImage *ec2.Image, rootVolumeSiz
generatingNewBlockDeviceMappings := config.FromScratch || len(config.AMIMappings) > 0
if generatingNewBlockDeviceMappings {
mappings = config.AMIMappings.Build()
mappings = config.AMIMappings.BuildEC2BlockDeviceMappings()
rootDeviceName = config.RootDeviceName
} else {
// If config.FromScratch is false, source image must be set

View File

@ -58,7 +58,7 @@ type BlockDevice struct {
type BlockDevices []BlockDevice
func (bds BlockDevices) Build() []*ec2.BlockDeviceMapping {
func (bds BlockDevices) BuildEC2BlockDeviceMappings() []*ec2.BlockDeviceMapping {
var blockDevices []*ec2.BlockDeviceMapping
for _, blockDevice := range bds {

View File

@ -151,13 +151,13 @@ func TestBlockDevice(t *testing.T) {
expected := []*ec2.BlockDeviceMapping{tc.Result}
amiResults := amiBlockDevices.Build()
amiResults := amiBlockDevices.BuildEC2BlockDeviceMappings()
if !reflect.DeepEqual(expected, amiResults) {
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v",
expected, amiResults)
}
launchResults := launchBlockDevices.Build()
launchResults := launchBlockDevices.BuildEC2BlockDeviceMappings()
if !reflect.DeepEqual(expected, launchResults) {
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v",
expected, launchResults)

View File

@ -21,7 +21,7 @@ import (
type StepRunSourceInstance struct {
AssociatePublicIpAddress bool
LaunchMappings BlockDevices
LaunchMappings BlockDevices
Comm *communicator.Config
Ctx interpolate.Context
Debug bool
@ -111,7 +111,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
MaxCount: aws.Int64(1),
MinCount: aws.Int64(1),
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Name: &s.IamInstanceProfile},
BlockDeviceMappings: s.LaunchMappings.Build(),
BlockDeviceMappings: s.LaunchMappings.BuildEC2BlockDeviceMappings(),
Placement: &ec2.Placement{AvailabilityZone: &az},
EbsOptimized: &s.EbsOptimized,
}

View File

@ -106,7 +106,7 @@ func (s *StepRunSpotInstance) CreateTemplateData(userData *string, az string,
// LaunchTemplateEbsBlockDeviceRequest structs are themselves
// identical except for the struct's name, so you can cast one directly
// into the other.
blockDeviceMappings := s.LaunchMappings.Build()
blockDeviceMappings := s.LaunchMappings.BuildEC2BlockDeviceMappings()
var launchMappingRequests []*ec2.LaunchTemplateBlockDeviceMappingRequest
for _, mapping := range blockDeviceMappings {
launchRequest := &ec2.LaunchTemplateBlockDeviceMappingRequest{

View File

@ -35,7 +35,7 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi
createOpts := &ec2.CreateImageInput{
InstanceId: instance.InstanceId,
Name: &amiName,
BlockDeviceMappings: config.AMIMappings.Build(),
BlockDeviceMappings: config.AMIMappings.BuildEC2BlockDeviceMappings(),
}
createResp, err := ec2conn.CreateImage(createOpts)

View File

@ -198,8 +198,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
}
}
amiDevices := b.config.AMIMappings.Build()
launchDevices := b.config.LaunchMappings.Build()
amiDevices := b.config.AMIMappings.BuildEC2BlockDeviceMappings()
launchDevices := b.config.LaunchMappings.BuildEC2BlockDeviceMappings()
// Build the steps
steps := []multistep.Step{

View File

@ -26,7 +26,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul
registerOpts := &ec2.RegisterImageInput{
ImageLocation: &manifestPath,
Name: aws.String(config.AMIName),
BlockDeviceMappings: config.AMIMappings.Build(),
BlockDeviceMappings: config.AMIMappings.BuildEC2BlockDeviceMappings(),
}
if config.AMIVirtType != "" {