github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/builder/openstack/artifact.go (about)

     1  package openstack
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"github.com/mitchellh/gophercloud-fork-40444fb"
     8  )
     9  
    10  // Artifact is an artifact implementation that contains built images.
    11  type Artifact struct {
    12  	// ImageId of built image
    13  	ImageId string
    14  
    15  	// BuilderId is the unique ID for the builder that created this image
    16  	BuilderIdValue string
    17  
    18  	// OpenStack connection for performing API stuff.
    19  	Conn gophercloud.CloudServersProvider
    20  }
    21  
    22  func (a *Artifact) BuilderId() string {
    23  	return a.BuilderIdValue
    24  }
    25  
    26  func (*Artifact) Files() []string {
    27  	// We have no files
    28  	return nil
    29  }
    30  
    31  func (a *Artifact) Id() string {
    32  	return a.ImageId
    33  }
    34  
    35  func (a *Artifact) String() string {
    36  	return fmt.Sprintf("An image was created: %v", a.ImageId)
    37  }
    38  
    39  func (a *Artifact) State(name string) interface{} {
    40  	return nil
    41  }
    42  
    43  func (a *Artifact) Destroy() error {
    44  	log.Printf("Destroying image: %d", a.ImageId)
    45  	return a.Conn.DeleteImageById(a.ImageId)
    46  }