First cut at vagrant post-processor for docker

This commit is contained in:
Patrick Double 2018-07-06 17:11:24 -05:00
parent 4b1f96b527
commit e7fc651f60
4 changed files with 54 additions and 12 deletions

4
Vagrantfile vendored
View File

@ -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

View File

@ -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
`

View File

@ -0,0 +1,9 @@
package vagrant
import (
"testing"
)
func TestDockerProvider_impl(t *testing.T) {
var _ Provider = new(DockerProvider)
}

View File

@ -31,6 +31,7 @@ var builtins = map[string]string{
"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
}