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
d03c852a
Commit
d03c852a
authored
Aug 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/common: move tags into ami_config
parent
ef142ce8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
34 deletions
+32
-34
builder/amazon/common/ami_config.go
builder/amazon/common/ami_config.go
+28
-6
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+4
-28
No files found.
builder/amazon/common/ami_config.go
View file @
d03c852a
...
...
@@ -8,12 +8,13 @@ import (
// AMIConfig is for common configuration related to creating AMIs.
type
AMIConfig
struct
{
AMIName
string
`mapstructure:"ami_name"`
AMIDescription
string
`mapstructure:"ami_description"`
AMIUsers
[]
string
`mapstructure:"ami_users"`
AMIGroups
[]
string
`mapstructure:"ami_groups"`
AMIProductCodes
[]
string
`mapstructure:"ami_product_codes"`
AMIRegions
[]
string
`mapstructure:"ami_regions"`
AMIName
string
`mapstructure:"ami_name"`
AMIDescription
string
`mapstructure:"ami_description"`
AMIUsers
[]
string
`mapstructure:"ami_users"`
AMIGroups
[]
string
`mapstructure:"ami_groups"`
AMIProductCodes
[]
string
`mapstructure:"ami_product_codes"`
AMIRegions
[]
string
`mapstructure:"ami_regions"`
AMITags
map
[
string
]
string
`mapstructure:"tags"`
}
func
(
c
*
AMIConfig
)
Prepare
(
t
*
packer
.
ConfigTemplate
)
[]
error
{
...
...
@@ -87,6 +88,27 @@ func (c *AMIConfig) Prepare(t *packer.ConfigTemplate) []error {
c
.
AMIRegions
=
regions
}
newTags
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
c
.
AMITags
{
k
,
err
:=
t
.
Process
(
k
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing tag key %s: %s"
,
k
,
err
))
continue
}
v
,
err
:=
t
.
Process
(
v
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing tag value '%s': %s"
,
v
,
err
))
continue
}
newTags
[
k
]
=
v
}
c
.
AMITags
=
newTags
if
len
(
errs
)
>
0
{
return
errs
}
...
...
builder/amazon/ebs/builder.go
View file @
d03c852a
...
...
@@ -6,7 +6,6 @@
package
ebs
import
(
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep"
awscommon
"github.com/mitchellh/packer/builder/amazon/common"
...
...
@@ -25,9 +24,6 @@ type config struct {
awscommon
.
BlockDevices
`mapstructure:",squash"`
awscommon
.
RunConfig
`mapstructure:",squash"`
// Tags for the AMI
Tags
map
[
string
]
string
tpl
*
packer
.
ConfigTemplate
}
...
...
@@ -54,28 +50,6 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
// Accumulate any errors
newTags
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
b
.
config
.
Tags
{
k
,
err
=
b
.
config
.
tpl
.
Process
(
k
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing tag key %s: %s"
,
k
,
err
))
continue
}
v
,
err
=
b
.
config
.
tpl
.
Process
(
v
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing tag value '%s': %s"
,
v
,
err
))
continue
}
newTags
[
k
]
=
v
}
b
.
config
.
Tags
=
newTags
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
}
...
...
@@ -132,9 +106,11 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
stepCreateAMI
{},
&
awscommon
.
StepAMIRegionCopy
{
Regions
:
b
.
config
.
AMIRegions
,
Tags
:
b
.
config
.
Tags
,
Tags
:
b
.
config
.
AMITags
,
},
&
awscommon
.
StepCreateTags
{
Tags
:
b
.
config
.
AMITags
,
},
&
awscommon
.
StepCreateTags
{
Tags
:
b
.
config
.
Tags
},
&
awscommon
.
StepModifyAMIAttributes
{
Description
:
b
.
config
.
AMIDescription
,
Users
:
b
.
config
.
AMIUsers
,
...
...
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