Commit 3992f447 authored by Petr Hosek's avatar Petr Hosek

Extract Vagrant provider processing logic

This change extracts the provider processing logic to a separate method
which can be invoked from a subtype, providing a custom provider.
parent b1c80ce4
...@@ -64,20 +64,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -64,20 +64,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return nil return nil
} }
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { func (p *PostProcessor) PostProcessProvider(name string, provider Provider, ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
name, ok := builtins[artifact.BuilderId()]
if !ok {
return nil, false, fmt.Errorf(
"Unknown artifact type, can't build box: %s", artifact.BuilderId())
}
provider := providerForName(name)
if provider == nil {
// This shouldn't happen since we hard code all of these ourselves
panic(fmt.Sprintf("bad provider name: %s", name))
}
config := p.configs[""] config := p.configs[""]
if specificConfig, ok := p.configs[name]; ok { if specificConfig, ok := p.configs[name]; ok {
config = specificConfig config = specificConfig
...@@ -158,6 +145,23 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ...@@ -158,6 +145,23 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return NewArtifact(name, outputPath), provider.KeepInputArtifact(), nil return NewArtifact(name, outputPath), provider.KeepInputArtifact(), nil
} }
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {
name, ok := builtins[artifact.BuilderId()]
if !ok {
return nil, false, fmt.Errorf(
"Unknown artifact type, can't build box: %s", artifact.BuilderId())
}
provider := providerForName(name)
if provider == nil {
// This shouldn't happen since we hard code all of these ourselves
panic(fmt.Sprintf("bad provider name: %s", name))
}
return p.PostProcessProvider(name, provider, ui, artifact)
}
func (p *PostProcessor) configureSingle(config *Config, raws ...interface{}) error { func (p *PostProcessor) configureSingle(config *Config, raws ...interface{}) error {
md, err := common.DecodeConfig(config, raws...) md, err := common.DecodeConfig(config, raws...)
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment