post-procssor/vagrant: don't export some things

This commit is contained in:
Mitchell Hashimoto 2013-12-19 13:52:48 -08:00
parent 2f09eb5bba
commit 7b6bbbf42f
1 changed files with 15 additions and 15 deletions

View File

@ -34,23 +34,10 @@ type Config struct {
tpl *packer.ConfigTemplate tpl *packer.ConfigTemplate
} }
// OutputPathTemplate is the structure that is availalable within the
// OutputPath variables.
type OutputPathTemplate struct {
ArtifactId string
BuildName string
Provider string
}
type PostProcessor struct { type PostProcessor struct {
config Config config Config
} }
type VagrantfileTemplate struct {
ProviderVagrantfile string
CustomVagrantfile string
}
func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) Configure(raws ...interface{}) error {
md, err := common.DecodeConfig(&p.config, raws...) md, err := common.DecodeConfig(&p.config, raws...)
if err != nil { if err != nil {
@ -117,7 +104,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
ui.Say(fmt.Sprintf("Creating Vagrant box for '%s' provider", name)) ui.Say(fmt.Sprintf("Creating Vagrant box for '%s' provider", name))
outputPath, err := p.config.tpl.Process(p.config.OutputPath, &OutputPathTemplate{ outputPath, err := p.config.tpl.Process(p.config.OutputPath, &outputPathTemplate{
ArtifactId: artifact.Id(), ArtifactId: artifact.Id(),
BuildName: p.config.PackerBuildName, BuildName: p.config.PackerBuildName,
Provider: name, Provider: name,
@ -173,7 +160,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
} }
t := template.Must(template.New("root").Parse(boxVagrantfileContents)) t := template.Must(template.New("root").Parse(boxVagrantfileContents))
err = t.Execute(f, &VagrantfileTemplate{ err = t.Execute(f, &vagrantfileTemplate{
ProviderVagrantfile: vagrantfile, ProviderVagrantfile: vagrantfile,
CustomVagrantfile: customVagrantfile, CustomVagrantfile: customVagrantfile,
}) })
@ -199,6 +186,19 @@ func providerForName(name string) Provider {
} }
} }
// OutputPathTemplate is the structure that is availalable within the
// OutputPath variables.
type outputPathTemplate struct {
ArtifactId string
BuildName string
Provider string
}
type vagrantfileTemplate struct {
ProviderVagrantfile string
CustomVagrantfile string
}
const boxVagrantfileContents string = ` const boxVagrantfileContents string = `
# The contents below were provided by the Packer Vagrant post-processor # The contents below were provided by the Packer Vagrant post-processor
{{ .ProviderVagrantfile }} {{ .ProviderVagrantfile }}