github.com/angdraug/packer@v1.3.2/builder/oracle/oci/artifact.go (about)

     1  package oci
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/oracle/oci-go-sdk/core"
     8  )
     9  
    10  // Artifact is an artifact implementation that contains a built Custom Image.
    11  type Artifact struct {
    12  	Image  core.Image
    13  	Region string
    14  	driver Driver
    15  }
    16  
    17  // BuilderId uniquely identifies the builder.
    18  func (a *Artifact) BuilderId() string {
    19  	return BuilderId
    20  }
    21  
    22  // Files lists the files associated with an artifact. We don't have any files
    23  // as the custom image is stored server side.
    24  func (a *Artifact) Files() []string {
    25  	return nil
    26  }
    27  
    28  // Id returns the OCID of the associated Image.
    29  func (a *Artifact) Id() string {
    30  	return *a.Image.Id
    31  }
    32  
    33  func (a *Artifact) String() string {
    34  	var displayName string
    35  	if a.Image.DisplayName != nil {
    36  		displayName = *a.Image.DisplayName
    37  	}
    38  
    39  	return fmt.Sprintf(
    40  		"An image was created: '%v' (OCID: %v) in region '%v'",
    41  		displayName, *a.Image.Id, a.Region,
    42  	)
    43  }
    44  
    45  // State ...
    46  func (a *Artifact) State(name string) interface{} {
    47  	return nil
    48  }
    49  
    50  // Destroy deletes the custom image associated with the artifact.
    51  func (a *Artifact) Destroy() error {
    52  	return a.driver.DeleteImage(context.TODO(), *a.Image.Id)
    53  }