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
13a27dee
Commit
13a27dee
authored
Jun 18, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazonebs: Implement Artifact.Destroy
parent
b9fb065d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
builder/amazonebs/artifact.go
builder/amazonebs/artifact.go
+22
-2
builder/amazonebs/artifact_test.go
builder/amazonebs/artifact_test.go
+1
-1
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+6
-1
No files found.
builder/amazonebs/artifact.go
View file @
13a27dee
package
amazonebs
package
amazonebs
import
(
import
(
"errors"
"fmt"
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/packer/packer"
"log"
"strings"
"strings"
)
)
type
artifact
struct
{
type
artifact
struct
{
// A map of regions to AMI IDs.
// A map of regions to AMI IDs.
amis
map
[
string
]
string
amis
map
[
string
]
string
// EC2 connection for performing API stuff.
conn
*
ec2
.
EC2
}
}
func
(
*
artifact
)
BuilderId
()
string
{
func
(
*
artifact
)
BuilderId
()
string
{
...
@@ -36,5 +41,20 @@ func (a *artifact) String() string {
...
@@ -36,5 +41,20 @@ func (a *artifact) String() string {
}
}
func
(
a
*
artifact
)
Destroy
()
error
{
func
(
a
*
artifact
)
Destroy
()
error
{
return
errors
.
New
(
"not implemented yet"
)
errors
:=
make
([]
error
,
0
)
for
_
,
imageId
:=
range
a
.
amis
{
log
.
Printf
(
"Degistering image ID: %s"
,
imageId
)
if
_
,
err
:=
a
.
conn
.
DeregisterImage
(
imageId
);
err
!=
nil
{
errors
=
append
(
errors
,
err
)
}
// TODO(mitchellh): Delete the snapshots associated with an AMI too
}
if
len
(
errors
)
>
0
{
return
&
packer
.
MultiError
{
errors
}
}
return
nil
}
}
builder/amazonebs/artifact_test.go
View file @
13a27dee
...
@@ -25,7 +25,7 @@ west: bar`
...
@@ -25,7 +25,7 @@ west: bar`
amis
[
"east"
]
=
"foo"
amis
[
"east"
]
=
"foo"
amis
[
"west"
]
=
"bar"
amis
[
"west"
]
=
"bar"
a
:=
&
artifact
{
amis
}
a
:=
&
artifact
{
amis
,
nil
}
result
:=
a
.
String
()
result
:=
a
.
String
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
}
builder/amazonebs/builder.go
View file @
13a27dee
...
@@ -161,7 +161,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -161,7 +161,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}
}
// Build the artifact and return it
// Build the artifact and return it
return
&
artifact
{
state
[
"amis"
]
.
(
map
[
string
]
string
)},
nil
artifact
:=
&
artifact
{
amis
:
state
[
"amis"
]
.
(
map
[
string
]
string
),
conn
:
ec2conn
,
}
return
artifact
,
nil
}
}
func
(
b
*
Builder
)
Cancel
()
{
func
(
b
*
Builder
)
Cancel
()
{
...
...
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