packer-cn/builder/vagrant/artifact.go

58 lines
1.2 KiB
Go
Raw Normal View History

2019-01-11 17:06:15 -05:00
package vagrant
import (
"fmt"
"path/filepath"
"github.com/hashicorp/packer/packer"
)
// This is the common builder ID to all of these artifacts.
const BuilderId = "vagrant"
// Artifact is the result of running the vagrant builder, namely a set
// of files associated with the resulting machine.
type artifact struct {
OutputDir string
BoxName string
Provider string
// StateData should store data such as GeneratedData
// to be shared with post-processors
StateData map[string]interface{}
2019-01-11 17:06:15 -05:00
}
// NewArtifact returns a vagrant artifact containing the .box file
func NewArtifact(provider, dir string, generatedData map[string]interface{}) packer.Artifact {
2019-01-11 17:06:15 -05:00
return &artifact{
OutputDir: dir,
BoxName: "package.box",
Provider: provider,
StateData: generatedData,
}
2019-01-11 17:06:15 -05:00
}
func (*artifact) BuilderId() string {
return BuilderId
}
func (a *artifact) Files() []string {
return []string{filepath.Join(a.OutputDir, a.BoxName)}
2019-01-11 17:06:15 -05:00
}
func (a *artifact) Id() string {
return a.Provider
2019-01-11 17:06:15 -05:00
}
func (a *artifact) String() string {
return fmt.Sprintf("Vagrant box '%s' for '%s' provider", a.BoxName, a.Provider)
2019-01-11 17:06:15 -05:00
}
func (a *artifact) State(name string) interface{} {
return a.StateData[name]
2019-01-11 17:06:15 -05:00
}
func (a *artifact) Destroy() error {
return nil
}