builder/googlecompute: get rid of all client stuff for now

This commit is contained in:
Mitchell Hashimoto 2013-12-12 21:41:14 -08:00
parent 52f51a1dcd
commit 54d59fc79f
2 changed files with 12 additions and 11 deletions

View File

@ -8,7 +8,7 @@ import (
// Artifact represents a GCE image as the result of a Packer build. // Artifact represents a GCE image as the result of a Packer build.
type Artifact struct { type Artifact struct {
imageName string imageName string
client *GoogleComputeClient driver Driver
} }
// BuilderId returns the builder Id. // BuilderId returns the builder Id.
@ -19,11 +19,13 @@ 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)
/*
// Ignore the operation result as we are not waiting until it completes. // Ignore the operation result as we are not waiting until it completes.
_, err := a.client.DeleteImage(a.imageName) _, err := a.client.DeleteImage(a.imageName)
if err != nil { if err != nil {
return err return err
} }
*/
return nil return nil
} }

View File

@ -33,17 +33,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Run executes a googlecompute Packer build and returns a packer.Artifact // Run executes a googlecompute Packer build and returns a packer.Artifact
// representing a GCE machine image. // representing a GCE machine image.
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
// Initialize the Google Compute Engine API. driver, err := NewDriverGCE(
client, err := New(b.config.ProjectId, b.config.Zone, b.config.clientSecrets, b.config.privateKeyBytes) ui, b.config.ProjectId, b.config.clientSecrets, b.config.privateKeyBytes)
if err != nil { if err != nil {
log.Println("Failed to create the Google Compute Engine client.")
return nil, err return nil, err
} }
// Set up the state. // Set up the state.
state := new(multistep.BasicStateBag) state := new(multistep.BasicStateBag)
state.Put("config", b.config) state.Put("config", b.config)
state.Put("client", client) state.Put("driver", driver)
state.Put("hook", hook) state.Put("hook", hook)
state.Put("ui", ui) state.Put("ui", ui)
@ -88,7 +87,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
artifact := &Artifact{ artifact := &Artifact{
imageName: state.Get("image_name").(string), imageName: state.Get("image_name").(string),
client: client, driver: driver,
} }
return artifact, nil return artifact, nil
} }