2013-12-08 17:37:36 -05:00
|
|
|
package googlecompute
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Artifact represents a GCE image as the result of a Packer build.
|
|
|
|
type Artifact struct {
|
|
|
|
imageName string
|
2013-12-13 00:41:14 -05:00
|
|
|
driver Driver
|
2013-12-08 17:37:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// BuilderId returns the builder Id.
|
|
|
|
func (*Artifact) BuilderId() string {
|
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy destroys the GCE image represented by the artifact.
|
|
|
|
func (a *Artifact) Destroy() error {
|
|
|
|
log.Printf("Destroying image: %s", a.imageName)
|
2013-12-13 22:07:10 -05:00
|
|
|
errCh := a.driver.DeleteImage(a.imageName)
|
|
|
|
return <-errCh
|
2013-12-08 17:37:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Files returns the files represented by the artifact.
|
|
|
|
func (*Artifact) Files() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Id returns the GCE image name.
|
|
|
|
func (a *Artifact) Id() string {
|
|
|
|
return a.imageName
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns the string representation of the artifact.
|
|
|
|
func (a *Artifact) String() string {
|
|
|
|
return fmt.Sprintf("A disk image was created: %v", a.imageName)
|
|
|
|
}
|