command/build: Lexical scoping bug to get the right build

This commit is contained in:
Mitchell Hashimoto 2013-06-05 17:46:23 -07:00
parent dd4fb1d62a
commit 81595258be
1 changed files with 4 additions and 4 deletions

View File

@ -128,16 +128,16 @@ func (c Command) Run(env packer.Environment, args []string) int {
var wg sync.WaitGroup
artifacts := make(map[string]packer.Artifact)
for _, b := range builds {
log.Printf("Starting build run: %s", b.Name())
// Increment the waitgroup so we wait for this item to finish properly
wg.Add(1)
// Run the build in a goroutine
go func() {
go func(b packer.Build) {
defer wg.Done()
log.Printf("Starting build run: %s", b.Name())
artifacts[b.Name()] = b.Run(buildUis[b.Name()])
}()
}(b)
}
// Handle signals