packer-plugin-xenserver/builder/xenserver/artifact.go
Rob Dobson 4d634aaf70 Initial plugin for building XenServer images using Packer.IO
Signed-off-by: Rob Dobson <rob.dobson@citrix.com>
2014-11-10 18:16:02 +00:00

58 lines
1.0 KiB
Go

package xenserver
import (
"fmt"
"os"
"github.com/mitchellh/packer/packer"
"path/filepath"
)
type LocalArtifact struct {
dir string
f []string
}
func NewArtifact(dir string) (packer.Artifact, error) {
files := make([]string, 0, 1)
visit := func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
files = append(files, path)
}
return err
}
if err := filepath.Walk(dir, visit); err != nil {
return nil, err
}
return &LocalArtifact{
dir: dir,
f: files,
}, nil
}
func (*LocalArtifact) BuilderId() string {
return BuilderId
}
func (a *LocalArtifact) Files() []string {
return a.f
}
func (*LocalArtifact) Id() string {
return "VM"
}
func (a *LocalArtifact) String() string {
return fmt.Sprintf("VM files in directory: %s", a.dir)
}
func (a *LocalArtifact) State(name string) interface{} {
return nil
}
func (a *LocalArtifact) Destroy() error {
return os.RemoveAll(a.dir)
}