diff --git a/post-processor/vagrant/lxc.go b/post-processor/vagrant/lxc.go new file mode 100644 index 000000000..497bcc1cd --- /dev/null +++ b/post-processor/vagrant/lxc.go @@ -0,0 +1,30 @@ +package vagrant + +import ( + "fmt" + "github.com/mitchellh/packer/packer" + "path/filepath" +) + +type LxcProvider struct{} + +func (p *LxcProvider) KeepInputArtifact() bool { + return false +} + +func (p *LxcProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { + // Create the metadata + metadata = map[string]interface{}{"provider": "lxc"} + + // Copy all of the original contents into the temporary directory + for _, path := range artifact.Files() { + ui.Message(fmt.Sprintf("Copying: %s", path)) + + dstPath := filepath.Join(dir, filepath.Base(path)) + if err = CopyContents(dstPath, path); err != nil { + return + } + } + + return +} diff --git a/post-processor/vagrant/lxc_test.go b/post-processor/vagrant/lxc_test.go new file mode 100644 index 000000000..f3fbc320c --- /dev/null +++ b/post-processor/vagrant/lxc_test.go @@ -0,0 +1,9 @@ +package vagrant + +import ( + "testing" +) + +func TestLxcProvider_impl(t *testing.T) { + var _ Provider = new(LxcProvider) +} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index aa65b2292..9a20ed5ae 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -28,6 +28,7 @@ var builtins = map[string]string{ "packer.parallels": "parallels", "MSOpenTech.hyperv": "hyperv", "transcend.qemu": "libvirt", + "ustream.lxc": "lxc", } type Config struct { @@ -232,6 +233,8 @@ func providerForName(name string) Provider { return new(HypervProvider) case "libvirt": return new(LibVirtProvider) + case "lxc": + return new(LxcProvider) default: return nil }