github.phpd.cn/hashicorp/packer@v1.3.2/builder/qemu/artifact.go (about)

     1  package qemu
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  // Artifact is the result of running the Qemu builder, namely a set
     9  // of files associated with the resulting machine.
    10  type Artifact struct {
    11  	dir   string
    12  	f     []string
    13  	state map[string]interface{}
    14  }
    15  
    16  func (*Artifact) BuilderId() string {
    17  	return BuilderId
    18  }
    19  
    20  func (a *Artifact) Files() []string {
    21  	return a.f
    22  }
    23  
    24  func (*Artifact) Id() string {
    25  	return "VM"
    26  }
    27  
    28  func (a *Artifact) String() string {
    29  	return fmt.Sprintf("VM files in directory: %s", a.dir)
    30  }
    31  
    32  func (a *Artifact) State(name string) interface{} {
    33  	return a.state[name]
    34  }
    35  
    36  func (a *Artifact) Destroy() error {
    37  	return os.RemoveAll(a.dir)
    38  }