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
cf6d2218
Commit
cf6d2218
authored
May 21, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazonebs: Artifact returns AMIs
parent
e9618b0d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
1 deletion
+77
-1
builder/amazonebs/artifact.go
builder/amazonebs/artifact.go
+35
-0
builder/amazonebs/artifact_test.go
builder/amazonebs/artifact_test.go
+31
-0
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+7
-1
builder/amazonebs/step_create_ami.go
builder/amazonebs/step_create_ami.go
+4
-0
No files found.
builder/amazonebs/artifact.go
0 → 100644
View file @
cf6d2218
package
amazonebs
import
(
"fmt"
"strings"
)
type
artifact
struct
{
// A map of regions to AMI IDs.
amis
map
[
string
]
string
}
func
(
*
artifact
)
BuilderId
()
string
{
return
BuilderId
}
func
(
*
artifact
)
Files
()
[]
string
{
// We have no files
return
nil
}
func
(
*
artifact
)
Id
()
string
{
// TODO(mitchellh): Id
return
"TODO"
}
func
(
a
*
artifact
)
String
()
string
{
amiStrings
:=
make
([]
string
,
0
,
len
(
a
.
amis
))
for
region
,
id
:=
range
a
.
amis
{
single
:=
fmt
.
Sprintf
(
"%s: %s"
,
region
,
id
)
amiStrings
=
append
(
amiStrings
,
single
)
}
return
fmt
.
Sprintf
(
"AMIs were created:
\n\n
%s"
,
strings
.
Join
(
amiStrings
,
"
\n
"
))
}
builder/amazonebs/artifact_test.go
0 → 100644
View file @
cf6d2218
package
amazonebs
import
(
"cgl.tideland.biz/asserts"
"github.com/mitchellh/packer/packer"
"testing"
)
func
TestArtifact_Impl
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
var
actual
packer
.
Artifact
assert
.
Implementor
(
&
artifact
{},
&
actual
,
"should be an Artifact"
)
}
func
TestArtifactString
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
expected
:=
`AMIs were created:
east: foo
west: bar`
amis
:=
make
(
map
[
string
]
string
)
amis
[
"east"
]
=
"foo"
amis
[
"west"
]
=
"bar"
a
:=
&
artifact
{
amis
}
result
:=
a
.
String
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
builder/amazonebs/builder.go
View file @
cf6d2218
...
...
@@ -13,6 +13,9 @@ import (
"log"
)
// The unique ID for this builder
const
BuilderId
=
"mitchellh.amazonebs"
type
config
struct
{
// Access information
AccessKey
string
`mapstructure:"access_key"`
...
...
@@ -45,7 +48,7 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
return
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
)
{
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
)
packer
.
Artifact
{
auth
:=
aws
.
Auth
{
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
}
region
:=
aws
.
Regions
[
b
.
config
.
Region
]
ec2conn
:=
ec2
.
New
(
auth
,
region
)
...
...
@@ -67,4 +70,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) {
// Run!
RunSteps
(
state
,
steps
)
// Build the artifact and return it
return
&
artifact
{
state
[
"amis"
]
.
(
map
[
string
]
string
)}
}
builder/amazonebs/step_create_ami.go
View file @
cf6d2218
...
...
@@ -26,7 +26,11 @@ func (s *stepCreateAMI) Run(state map[string]interface{}) StepAction {
return
StepHalt
}
// Set the AMI ID in the state
ui
.
Say
(
"AMI: %s"
,
createResp
.
ImageId
)
amis
:=
make
(
map
[
string
]
string
)
amis
[
config
.
Region
]
=
createResp
.
ImageId
state
[
"amis"
]
=
amis
// Wait for the image to become ready
ui
.
Say
(
"Waiting for AMI to become ready..."
)
...
...
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