github.com/raghuse92/packer@v1.3.2/builder/openstack/artifact.go (about)

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