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
992a9bfb
Commit
992a9bfb
authored
Jul 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/common: extract Artifact
parent
0a76d073
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
builder/amazon/common/artifact.go
builder/amazon/common/artifact.go
+20
-16
builder/amazon/common/artifact_test.go
builder/amazon/common/artifact_test.go
+4
-4
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+4
-3
No files found.
builder/amazon/
ebs
/artifact.go
→
builder/amazon/
common
/artifact.go
View file @
992a9bfb
package
ebs
package
common
import
(
"fmt"
...
...
@@ -8,35 +8,39 @@ import (
"strings"
)
type
artifact
struct
{
// Artifact is an artifact implementation that contains built AMIs.
type
Artifact
struct
{
// A map of regions to AMI IDs.
amis
map
[
string
]
string
Amis
map
[
string
]
string
// BuilderId is the unique ID for the builder that created this AMI
BuilderIdValue
string
// EC2 connection for performing API stuff.
c
onn
*
ec2
.
EC2
C
onn
*
ec2
.
EC2
}
func
(
*
a
rtifact
)
BuilderId
()
string
{
return
BuilderId
func
(
a
*
A
rtifact
)
BuilderId
()
string
{
return
a
.
BuilderIdValue
}
func
(
*
a
rtifact
)
Files
()
[]
string
{
func
(
*
A
rtifact
)
Files
()
[]
string
{
// We have no files
return
nil
}
func
(
a
*
a
rtifact
)
Id
()
string
{
parts
:=
make
([]
string
,
0
,
len
(
a
.
a
mis
))
for
region
,
amiId
:=
range
a
.
a
mis
{
func
(
a
*
A
rtifact
)
Id
()
string
{
parts
:=
make
([]
string
,
0
,
len
(
a
.
A
mis
))
for
region
,
amiId
:=
range
a
.
A
mis
{
parts
=
append
(
parts
,
fmt
.
Sprintf
(
"%s:%s"
,
region
,
amiId
))
}
return
strings
.
Join
(
parts
,
","
)
}
func
(
a
*
a
rtifact
)
String
()
string
{
amiStrings
:=
make
([]
string
,
0
,
len
(
a
.
a
mis
))
for
region
,
id
:=
range
a
.
a
mis
{
func
(
a
*
A
rtifact
)
String
()
string
{
amiStrings
:=
make
([]
string
,
0
,
len
(
a
.
A
mis
))
for
region
,
id
:=
range
a
.
A
mis
{
single
:=
fmt
.
Sprintf
(
"%s: %s"
,
region
,
id
)
amiStrings
=
append
(
amiStrings
,
single
)
}
...
...
@@ -44,12 +48,12 @@ func (a *artifact) String() string {
return
fmt
.
Sprintf
(
"AMIs were created:
\n\n
%s"
,
strings
.
Join
(
amiStrings
,
"
\n
"
))
}
func
(
a
*
a
rtifact
)
Destroy
()
error
{
func
(
a
*
A
rtifact
)
Destroy
()
error
{
errors
:=
make
([]
error
,
0
)
for
_
,
imageId
:=
range
a
.
a
mis
{
for
_
,
imageId
:=
range
a
.
A
mis
{
log
.
Printf
(
"Deregistering image ID: %s"
,
imageId
)
if
_
,
err
:=
a
.
c
onn
.
DeregisterImage
(
imageId
);
err
!=
nil
{
if
_
,
err
:=
a
.
C
onn
.
DeregisterImage
(
imageId
);
err
!=
nil
{
errors
=
append
(
errors
,
err
)
}
...
...
builder/amazon/
ebs
/artifact_test.go
→
builder/amazon/
common
/artifact_test.go
View file @
992a9bfb
package
ebs
package
common
import
(
"cgl.tideland.biz/asserts"
...
...
@@ -10,7 +10,7 @@ func TestArtifact_Impl(t *testing.T) {
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
var
actual
packer
.
Artifact
assert
.
Implementor
(
&
a
rtifact
{},
&
actual
,
"should be an Artifact"
)
assert
.
Implementor
(
&
A
rtifact
{},
&
actual
,
"should be an Artifact"
)
}
func
TestArtifactId
(
t
*
testing
.
T
)
{
...
...
@@ -22,7 +22,7 @@ func TestArtifactId(t *testing.T) {
amis
[
"east"
]
=
"foo"
amis
[
"west"
]
=
"bar"
a
:=
&
a
rtifact
{
amis
,
nil
}
a
:=
&
A
rtifact
{
amis
,
nil
}
result
:=
a
.
Id
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
...
...
@@ -39,7 +39,7 @@ west: bar`
amis
[
"east"
]
=
"foo"
amis
[
"west"
]
=
"bar"
a
:=
&
a
rtifact
{
amis
,
nil
}
a
:=
&
A
rtifact
{
amis
,
nil
}
result
:=
a
.
String
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
builder/amazon/ebs/builder.go
View file @
992a9bfb
...
...
@@ -131,9 +131,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}
// Build the artifact and return it
artifact
:=
&
artifact
{
amis
:
state
[
"amis"
]
.
(
map
[
string
]
string
),
conn
:
ec2conn
,
artifact
:=
&
awscommon
.
Artifact
{
Amis
:
state
[
"amis"
]
.
(
map
[
string
]
string
),
BuilderIdValue
:
BuilderId
,
Conn
:
ec2conn
,
}
return
artifact
,
nil
...
...
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