packer-cn/builder/openstack/artifact.go

48 lines
969 B
Go
Raw Normal View History

2013-08-28 01:35:59 -04:00
package openstack
import (
"fmt"
"log"
2015-06-12 00:16:43 -04:00
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/compute/v2/images"
2013-08-28 01:35:59 -04:00
)
// 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.
2015-06-12 00:16:43 -04:00
Client *gophercloud.ServiceClient
2013-08-28 01:35:59 -04:00
}
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) State(name string) interface{} {
return nil
}
2013-08-28 01:35:59 -04:00
func (a *Artifact) Destroy() error {
log.Printf("Destroying image: %s", a.ImageId)
2015-06-12 00:16:43 -04:00
return images.Delete(a.Client, a.ImageId).ExtractErr()
2013-08-28 01:35:59 -04:00
}