90a57c411f
In order that something consuming an artifact can have access to extra builder specific data add the State method which allows the caller to ask for arbitary values by name.
45 lines
690 B
Go
45 lines
690 B
Go
package vagrant
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
const BuilderId = "mitchellh.post-processor.vagrant"
|
|
|
|
type Artifact struct {
|
|
Path string
|
|
Provider string
|
|
}
|
|
|
|
func NewArtifact(provider, path string) *Artifact {
|
|
return &Artifact{
|
|
Path: path,
|
|
Provider: provider,
|
|
}
|
|
}
|
|
|
|
func (*Artifact) BuilderId() string {
|
|
return BuilderId
|
|
}
|
|
|
|
func (a *Artifact) Files() []string {
|
|
return []string{a.Path}
|
|
}
|
|
|
|
func (a *Artifact) Id() string {
|
|
return a.Provider
|
|
}
|
|
|
|
func (a *Artifact) String() string {
|
|
return fmt.Sprintf("'%s' provider box: %s", a.Provider, a.Path)
|
|
}
|
|
|
|
func (a *Artifact) State(name string) interface{} {
|
|
return nil
|
|
}
|
|
|
|
func (a *Artifact) Destroy() error {
|
|
return os.Remove(a.Path)
|
|
}
|