Skip to content

Commit

Permalink
First cut at vagrant post-processor for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
double16 committed Jul 6, 2018
1 parent 4b1f96b commit e7fc651
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions post-processor/vagrant/docker.go
Original file line number Diff line number Diff line change
@@ -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
`
9 changes: 9 additions & 0 deletions post-processor/vagrant/docker_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package vagrant

import (
"testing"
)

func TestDockerProvider_impl(t *testing.T) {
var _ Provider = new(DockerProvider)
}
27 changes: 15 additions & 12 deletions post-processor/vagrant/post-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e7fc651

Please sign in to comment.