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
30ab6572
Commit
30ab6572
authored
Aug 27, 2013
by
Mark Peek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/openstack: return artifacts
parent
276c023d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
2 deletions
+88
-2
builder/openstack/artifact.go
builder/openstack/artifact.go
+41
-0
builder/openstack/artifact_test.go
builder/openstack/artifact_test.go
+39
-0
builder/openstack/builder.go
builder/openstack/builder.go
+8
-2
No files found.
builder/openstack/artifact.go
0 → 100644
View file @
30ab6572
package
openstack
import
(
"fmt"
"github.com/rackspace/gophercloud"
"log"
)
// Artifact is an artifact implementation that contains built images.
type
Artifact
struct
{
// ImageId of built image
ImageId
string
// BuilderId is the unique ID for the builder that created this image
BuilderIdValue
string
// OpenStack connection for performing API stuff.
Conn
gophercloud
.
CloudServersProvider
}
func
(
a
*
Artifact
)
BuilderId
()
string
{
return
a
.
BuilderIdValue
}
func
(
*
Artifact
)
Files
()
[]
string
{
// We have no files
return
nil
}
func
(
a
*
Artifact
)
Id
()
string
{
return
a
.
ImageId
}
func
(
a
*
Artifact
)
String
()
string
{
return
fmt
.
Sprintf
(
"An image was created: %v"
,
a
.
ImageId
)
}
func
(
a
*
Artifact
)
Destroy
()
error
{
log
.
Printf
(
"Destroying image: %d"
,
a
.
ImageId
)
return
a
.
Conn
.
DeleteImageById
(
a
.
ImageId
)
}
builder/openstack/artifact_test.go
0 → 100644
View file @
30ab6572
package
openstack
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
TestArtifactId
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
expected
:=
`b8cdf55b-c916-40bd-b190-389ec144c4ed`
a
:=
&
Artifact
{
ImageId
:
"b8cdf55b-c916-40bd-b190-389ec144c4ed"
,
}
result
:=
a
.
Id
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
func
TestArtifactString
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
expected
:=
"An image was created: b8cdf55b-c916-40bd-b190-389ec144c4ed"
a
:=
&
Artifact
{
ImageId
:
"b8cdf55b-c916-40bd-b190-389ec144c4ed"
,
}
result
:=
a
.
String
()
assert
.
Equal
(
result
,
expected
,
"should match output"
)
}
builder/openstack/builder.go
View file @
30ab6572
...
...
@@ -112,8 +112,14 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return
nil
,
rawErr
.
(
error
)
}
// XXX - add artifact
return
nil
,
nil
// Build the artifact and return it
artifact
:=
&
Artifact
{
ImageId
:
state
[
"image"
]
.
(
string
),
BuilderIdValue
:
BuilderId
,
Conn
:
csp
,
}
return
artifact
,
nil
}
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