2018-07-06 18:11:24 -04:00
|
|
|
package vagrant
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-11-19 14:54:31 -05:00
|
|
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
2018-07-06 18:11:24 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type DockerProvider struct{}
|
|
|
|
|
|
|
|
func (p *DockerProvider) KeepInputArtifact() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:17:11 -05:00
|
|
|
func (p *DockerProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) {
|
2018-07-06 18:11:24 -04:00
|
|
|
// Create the metadata
|
|
|
|
metadata = map[string]interface{}{"provider": "docker"}
|
|
|
|
|
2018-07-16 16:35:02 -04:00
|
|
|
vagrantfile = fmt.Sprintf(dockerVagrantfile, artifact.Id())
|
2018-07-06 18:11:24 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var dockerVagrantfile = `
|
|
|
|
Vagrant.configure("2") do |config|
|
2018-07-16 16:35:02 -04:00
|
|
|
config.vm.provider :docker do |docker, override|
|
|
|
|
docker.image = "%s"
|
|
|
|
end
|
2018-07-06 18:11:24 -04:00
|
|
|
end
|
|
|
|
`
|