Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
5db91c84
Commit
5db91c84
authored
Sep 05, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon: string fields on device mappings can use variables
parent
41372c4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
0 deletions
+51
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
builder/amazon/common/block_device.go
builder/amazon/common/block_device.go
+48
-0
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+1
-0
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+1
-0
No files found.
CHANGELOG.md
View file @
5db91c84
...
...
@@ -30,6 +30,7 @@ IMPROVEMENTS:
set with the
`token`
configuration. [GH-1236]
*
builder/amazon/all: Can force SSH on the private IP address with
`ssh_private_ip`
. [GH-1229]
*
builder/amazon/all: String fields in device mappings can use variables. [GH-1090]
*
builder/amazon-instance: EBS AMIs can be used as a source. [GH-1453]
*
builder/digitalocean: Can set API URL endpoint. [GH-1448]
*
builder/digitalocean: Region supports variables. [GH-1452]
...
...
builder/amazon/common/block_device.go
View file @
5db91c84
package
common
import
(
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/packer/packer"
)
// BlockDevice
...
...
@@ -41,6 +44,51 @@ func buildBlockDevices(b []BlockDevice) []ec2.BlockDeviceMapping {
return
blockDevices
}
func
(
b
*
BlockDevices
)
Prepare
(
t
*
packer
.
ConfigTemplate
)
[]
error
{
if
t
==
nil
{
var
err
error
t
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
[]
error
{
err
}
}
}
lists
:=
map
[
string
][]
BlockDevice
{
"ami_block_device_mappings"
:
b
.
AMIMappings
,
"launch_block_device_mappings"
:
b
.
LaunchMappings
,
}
var
errs
[]
error
for
outer
,
bds
:=
range
lists
{
for
i
,
bd
:=
range
bds
{
templates
:=
map
[
string
]
*
string
{
"device_name"
:
&
bd
.
DeviceName
,
"snapshot_id"
:
&
bd
.
SnapshotId
,
"virtual_name"
:
&
bd
.
VirtualName
,
"volume_type"
:
&
bd
.
VolumeType
,
}
errs
:=
make
([]
error
,
0
)
for
n
,
ptr
:=
range
templates
{
var
err
error
*
ptr
,
err
=
t
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing %s[%d].%s: %s"
,
outer
,
i
,
n
,
err
))
}
}
}
}
if
len
(
errs
)
>
0
{
return
errs
}
return
nil
}
func
(
b
*
BlockDevices
)
BuildAMIDevices
()
[]
ec2
.
BlockDeviceMapping
{
return
buildBlockDevices
(
b
.
AMIMappings
)
}
...
...
builder/amazon/ebs/builder.go
View file @
5db91c84
...
...
@@ -50,6 +50,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
...
...
builder/amazon/instance/builder.go
View file @
5db91c84
...
...
@@ -99,6 +99,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment