56 lines
933 B
Go
56 lines
933 B
Go
package xenserver
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/mitchellh/packer/packer"
|
|
"os"
|
|
"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)
|
|
}
|