github.com/aclaygray/packer@v1.3.2/post-processor/vagrant/google.go (about) 1 package vagrant 2 3 import ( 4 "bytes" 5 "text/template" 6 7 "github.com/hashicorp/packer/packer" 8 ) 9 10 type googleVagrantfileTemplate struct { 11 Image string "" 12 } 13 14 type GoogleProvider struct{} 15 16 func (p *GoogleProvider) KeepInputArtifact() bool { 17 return true 18 } 19 20 func (p *GoogleProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { 21 // Create the metadata 22 metadata = map[string]interface{}{"provider": "google"} 23 24 // Build up the template data to build our Vagrantfile 25 tplData := &googleVagrantfileTemplate{} 26 tplData.Image = artifact.Id() 27 28 // Build up the Vagrantfile 29 var contents bytes.Buffer 30 t := template.Must(template.New("vf").Parse(defaultGoogleVagrantfile)) 31 err = t.Execute(&contents, tplData) 32 vagrantfile = contents.String() 33 return 34 } 35 36 var defaultGoogleVagrantfile = ` 37 Vagrant.configure("2") do |config| 38 config.vm.provider :google do |google| 39 google.image = "{{ .Image }}" 40 end 41 end 42 `