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
637968f2
Commit
637968f2
authored
Dec 13, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/googlecompute: artifact uses Driver, no more api
parent
33a84c09
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
69 deletions
+33
-69
builder/googlecompute/api.go
builder/googlecompute/api.go
+0
-23
builder/googlecompute/artifact.go
builder/googlecompute/artifact.go
+2
-8
builder/googlecompute/driver.go
builder/googlecompute/driver.go
+3
-0
builder/googlecompute/driver_gce.go
builder/googlecompute/driver_gce.go
+12
-0
builder/googlecompute/driver_mock.go
builder/googlecompute/driver_mock.go
+16
-0
builder/googlecompute/wait.go
builder/googlecompute/wait.go
+0
-38
No files found.
builder/googlecompute/api.go
deleted
100644 → 0
View file @
33a84c09
package
googlecompute
import
(
"code.google.com/p/google-api-go-client/compute/v1beta16"
)
// GoogleComputeClient represents a GCE client.
type
GoogleComputeClient
struct
{
ProjectId
string
Service
*
compute
.
Service
Zone
string
clientSecrets
*
clientSecrets
}
// DeleteImage deletes the named image. Returns a Global Operation.
func
(
g
*
GoogleComputeClient
)
DeleteImage
(
name
string
)
(
*
compute
.
Operation
,
error
)
{
imagesDeleteCall
:=
g
.
Service
.
Images
.
Delete
(
g
.
ProjectId
,
name
)
operation
,
err
:=
imagesDeleteCall
.
Do
()
if
err
!=
nil
{
return
nil
,
err
}
return
operation
,
nil
}
builder/googlecompute/artifact.go
View file @
637968f2
...
@@ -19,14 +19,8 @@ func (*Artifact) BuilderId() string {
...
@@ -19,14 +19,8 @@ func (*Artifact) BuilderId() string {
// Destroy destroys the GCE image represented by the artifact.
// Destroy destroys the GCE image represented by the artifact.
func
(
a
*
Artifact
)
Destroy
()
error
{
func
(
a
*
Artifact
)
Destroy
()
error
{
log
.
Printf
(
"Destroying image: %s"
,
a
.
imageName
)
log
.
Printf
(
"Destroying image: %s"
,
a
.
imageName
)
/*
errCh
:=
a
.
driver
.
DeleteImage
(
a
.
imageName
)
// Ignore the operation result as we are not waiting until it completes.
return
<-
errCh
_, err := a.client.DeleteImage(a.imageName)
if err != nil {
return err
}
*/
return
nil
}
}
// Files returns the files represented by the artifact.
// Files returns the files represented by the artifact.
...
...
builder/googlecompute/driver.go
View file @
637968f2
...
@@ -7,6 +7,9 @@ type Driver interface {
...
@@ -7,6 +7,9 @@ type Driver interface {
// CreateImage creates an image with the given URL in Google Storage.
// CreateImage creates an image with the given URL in Google Storage.
CreateImage
(
name
,
description
,
url
string
)
<-
chan
error
CreateImage
(
name
,
description
,
url
string
)
<-
chan
error
// DeleteImage deletes the image with the given name.
DeleteImage
(
name
string
)
<-
chan
error
// DeleteInstance deletes the given instance.
// DeleteInstance deletes the given instance.
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
...
...
builder/googlecompute/driver_gce.go
View file @
637968f2
...
@@ -81,6 +81,18 @@ func (d *driverGCE) CreateImage(name, description, url string) <-chan error {
...
@@ -81,6 +81,18 @@ func (d *driverGCE) CreateImage(name, description, url string) <-chan error {
return
errCh
return
errCh
}
}
func
(
d
*
driverGCE
)
DeleteImage
(
name
string
)
<-
chan
error
{
errCh
:=
make
(
chan
error
,
1
)
op
,
err
:=
d
.
service
.
Images
.
Delete
(
d
.
projectId
,
name
)
.
Do
()
if
err
!=
nil
{
errCh
<-
err
}
else
{
go
waitForState
(
errCh
,
"DONE"
,
d
.
refreshGlobalOp
(
op
))
}
return
errCh
}
func
(
d
*
driverGCE
)
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
{
func
(
d
*
driverGCE
)
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
{
op
,
err
:=
d
.
service
.
Instances
.
Delete
(
d
.
projectId
,
zone
,
name
)
.
Do
()
op
,
err
:=
d
.
service
.
Instances
.
Delete
(
d
.
projectId
,
zone
,
name
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
builder/googlecompute/driver_mock.go
View file @
637968f2
...
@@ -8,6 +8,9 @@ type DriverMock struct {
...
@@ -8,6 +8,9 @@ type DriverMock struct {
CreateImageURL
string
CreateImageURL
string
CreateImageErrCh
<-
chan
error
CreateImageErrCh
<-
chan
error
DeleteImageName
string
DeleteImageErrCh
<-
chan
error
DeleteInstanceZone
string
DeleteInstanceZone
string
DeleteInstanceName
string
DeleteInstanceName
string
DeleteInstanceErrCh
<-
chan
error
DeleteInstanceErrCh
<-
chan
error
...
@@ -43,6 +46,19 @@ func (d *DriverMock) CreateImage(name, description, url string) <-chan error {
...
@@ -43,6 +46,19 @@ func (d *DriverMock) CreateImage(name, description, url string) <-chan error {
return
resultCh
return
resultCh
}
}
func
(
d
*
DriverMock
)
DeleteImage
(
name
string
)
<-
chan
error
{
d
.
DeleteImageName
=
name
resultCh
:=
d
.
DeleteImageErrCh
if
resultCh
==
nil
{
ch
:=
make
(
chan
error
)
close
(
ch
)
resultCh
=
ch
}
return
resultCh
}
func
(
d
*
DriverMock
)
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
{
func
(
d
*
DriverMock
)
DeleteInstance
(
zone
,
name
string
)
(
<-
chan
error
,
error
)
{
d
.
DeleteInstanceZone
=
zone
d
.
DeleteInstanceZone
=
zone
d
.
DeleteInstanceName
=
name
d
.
DeleteInstanceName
=
name
...
...
builder/googlecompute/wait.go
deleted
100644 → 0
View file @
33a84c09
package
googlecompute
import
(
"time"
)
// waitForInstanceState.
func
waitForInstanceState
(
desiredState
string
,
zone
string
,
name
string
,
client
*
GoogleComputeClient
,
timeout
time
.
Duration
)
error
{
return
nil
/*
f := func() (string, error) {
return client.InstanceStatus(zone, name)
}
return waitForState("instance", desiredState, f, timeout)
*/
}
// waitForZoneOperationState.
func
waitForZoneOperationState
(
desiredState
string
,
zone
string
,
name
string
,
client
*
GoogleComputeClient
,
timeout
time
.
Duration
)
error
{
return
nil
/*
f := func() (string, error) {
return client.ZoneOperationStatus(zone, name)
}
return waitForState("operation", desiredState, f, timeout)
*/
}
// waitForGlobalOperationState.
func
waitForGlobalOperationState
(
desiredState
string
,
name
string
,
client
*
GoogleComputeClient
,
timeout
time
.
Duration
)
error
{
/*
f := func() (string, error) {
return client.GlobalOperationStatus(name)
}
return waitForState("operation", desiredState, f, timeout)
*/
return
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