github.com/Hashicorp/packer@v1.3.2/builder/triton/artifact.go (about)

     1  package triton
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  )
     7  
     8  // Artifact is an artifact implementation that contains built Triton images.
     9  type Artifact struct {
    10  	// ImageID is the image ID of the artifact
    11  	ImageID string
    12  
    13  	// BuilderIDValue is the unique ID for the builder that created this Image
    14  	BuilderIDValue string
    15  
    16  	// SDC connection for cleanup etc
    17  	Driver Driver
    18  }
    19  
    20  func (a *Artifact) BuilderId() string {
    21  	return a.BuilderIDValue
    22  }
    23  
    24  func (*Artifact) Files() []string {
    25  	return nil
    26  }
    27  
    28  func (a *Artifact) Id() string {
    29  	return a.ImageID
    30  }
    31  
    32  func (a *Artifact) String() string {
    33  	return fmt.Sprintf("Image was created: %s", a.ImageID)
    34  }
    35  
    36  func (a *Artifact) State(name string) interface{} {
    37  	//TODO(jen20): Figure out how to make this work with Atlas
    38  	return nil
    39  }
    40  
    41  func (a *Artifact) Destroy() error {
    42  	log.Printf("Deleting image ID (%s)", a.ImageID)
    43  	err := a.Driver.DeleteImage(a.ImageID)
    44  	if err != nil {
    45  		return err
    46  	}
    47  
    48  	return nil
    49  }