diff --git a/Vagrantfile b/Vagrantfile index dd6370f04..c998e31c0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,6 +5,10 @@ LINUX_BASE_BOX = "bento/ubuntu-16.04" FREEBSD_BASE_BOX = "jen20/FreeBSD-12.0-CURRENT" Vagrant.configure(2) do |config| + if Vagrant.has_plugin?("vagrant-cachier") + config.cache.scope = :box + end + # Compilation and development boxes config.vm.define "linux", autostart: true, primary: true do |vmCfg| vmCfg.vm.box = LINUX_BASE_BOX diff --git a/post-processor/vagrant/docker.go b/post-processor/vagrant/docker.go new file mode 100644 index 000000000..50b811c8f --- /dev/null +++ b/post-processor/vagrant/docker.go @@ -0,0 +1,26 @@ +package vagrant + +import ( + "fmt" + + "github.com/hashicorp/packer/packer" +) + +type DockerProvider struct{} + +func (p *DockerProvider) KeepInputArtifact() bool { + return false +} + +func (p *DockerProvider) 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": "docker"} + + vagrantfile = fmt.Sprintf(dockerVagrantfile) + return +} + +var dockerVagrantfile = ` +Vagrant.configure("2") do |config| +end +` diff --git a/post-processor/vagrant/docker_test.go b/post-processor/vagrant/docker_test.go new file mode 100644 index 000000000..380846bcc --- /dev/null +++ b/post-processor/vagrant/docker_test.go @@ -0,0 +1,9 @@ +package vagrant + +import ( + "testing" +) + +func TestDockerProvider_impl(t *testing.T) { + var _ Provider = new(DockerProvider) +} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index d4b587316..3d54d49f7 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -19,18 +19,19 @@ import ( ) var builtins = map[string]string{ - "mitchellh.amazonebs": "aws", - "mitchellh.amazon.instance": "aws", - "mitchellh.virtualbox": "virtualbox", - "mitchellh.vmware": "vmware", - "mitchellh.vmware-esx": "vmware", - "pearkes.digitalocean": "digitalocean", - "packer.googlecompute": "google", - "hashicorp.scaleway": "scaleway", - "packer.parallels": "parallels", - "MSOpenTech.hyperv": "hyperv", - "transcend.qemu": "libvirt", - "ustream.lxc": "lxc", + "mitchellh.amazonebs": "aws", + "mitchellh.amazon.instance": "aws", + "mitchellh.virtualbox": "virtualbox", + "mitchellh.vmware": "vmware", + "mitchellh.vmware-esx": "vmware", + "pearkes.digitalocean": "digitalocean", + "packer.googlecompute": "google", + "hashicorp.scaleway": "scaleway", + "packer.parallels": "parallels", + "MSOpenTech.hyperv": "hyperv", + "transcend.qemu": "libvirt", + "ustream.lxc": "lxc", + "packer.post-processor.docker-import": "docker", } type Config struct { @@ -241,6 +242,8 @@ func providerForName(name string) Provider { return new(GoogleProvider) case "lxc": return new(LXCProvider) + case "docker": + return new(DockerProvider) default: return nil }