Ability to get a builder from the env
This commit is contained in:
parent
6bed06e01c
commit
4eb8ac80c2
|
@ -34,6 +34,7 @@ type Command interface {
|
||||||
// if you're building a custom Packer binary, you could instantiate multiple
|
// if you're building a custom Packer binary, you could instantiate multiple
|
||||||
// environments and run them in parallel.
|
// environments and run them in parallel.
|
||||||
type Environment struct {
|
type Environment struct {
|
||||||
|
builder map[string]Builder
|
||||||
command map[string]Command
|
command map[string]Command
|
||||||
ui Ui
|
ui Ui
|
||||||
}
|
}
|
||||||
|
@ -41,6 +42,7 @@ type Environment struct {
|
||||||
// This creates a new environment
|
// This creates a new environment
|
||||||
func NewEnvironment() *Environment {
|
func NewEnvironment() *Environment {
|
||||||
env := &Environment{}
|
env := &Environment{}
|
||||||
|
env.builder = make(map[string]Builder)
|
||||||
env.command = make(map[string]Command)
|
env.command = make(map[string]Command)
|
||||||
env.command["build"] = new(buildCommand)
|
env.command["build"] = new(buildCommand)
|
||||||
env.command["version"] = new(versionCommand)
|
env.command["version"] = new(versionCommand)
|
||||||
|
@ -48,6 +50,12 @@ func NewEnvironment() *Environment {
|
||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Looks up a builder with the given name and returns an interface
|
||||||
|
// to access it.
|
||||||
|
func (e *Environment) Builder(name string) Builder {
|
||||||
|
return e.builder[name]
|
||||||
|
}
|
||||||
|
|
||||||
// Executes a command as if it was typed on the command-line interface.
|
// Executes a command as if it was typed on the command-line interface.
|
||||||
// The return value is the exit code of the command.
|
// The return value is the exit code of the command.
|
||||||
func (e *Environment) Cli(args []string) int {
|
func (e *Environment) Cli(args []string) int {
|
||||||
|
|
Loading…
Reference in New Issue