Skip to content

Commit

Permalink
resolv Puppetlabs Forge and Git modules in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
xorpaul committed Mar 18, 2016
1 parent faaa497 commit b9efde8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func doModuleInstallOrNothing(m string) {
fr := ForgeResult{false, ma[2]}
if moduleVersion == "latest" {
if _, err := os.Stat(workDir); os.IsNotExist(err) {
Debugf("doModuleInstallOrNothing(): " + workDir + " did not exists, fetching module")
Debugf("doModuleInstallOrNothing(): " + workDir + " does not exist, fetching module")
// check forge API what the latest version is
fr = queryForgeAPI(moduleName, "false")
if fr.needToGet {
Expand All @@ -48,7 +48,7 @@ func doModuleInstallOrNothing(m string) {
} else {
// check forge API if latest version of this module has been updated
Debugf("doModuleInstallOrNothing(): check forge API if latest version of module " + moduleName + " has been updated")
// XXX: disable adding If-Modified-Since head for now
// XXX: disable adding If-Modified-Since header for now
// because then the latestForgeModules does not get set with the actual module version for latest
// maybe if received 304 get the actual version from the -latest symlink
fr = queryForgeAPI(moduleName, "false")
Expand Down Expand Up @@ -184,6 +184,7 @@ func downloadForgeModule(name string, version string) {
}
client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
before := time.Now()
Debugf("GETing " + url)
resp, err := client.Do(req)
duration := time.Since(before).Seconds()
Verbosef("GETing " + url + " took " + strconv.FormatFloat(duration, 'f', 5, 64) + "s")
Expand Down
13 changes: 11 additions & 2 deletions puppetfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ func resolvePuppetfile(allPuppetfiles map[string]Puppetfile) {
}
}
//fmt.Println(uniqueGitModules)
resolveGitRepositories(uniqueGitModules)
resolveForgeModules(uniqueForgeModules)
var wgResolve sync.WaitGroup
wgResolve.Add(2)
go func() {
defer wgResolve.Done()
resolveGitRepositories(uniqueGitModules)
}()
go func() {
defer wgResolve.Done()
resolveForgeModules(uniqueForgeModules)
}()
wgResolve.Wait()
//log.Println(config.Sources["cmdlineparam"])
for env, pf := range allPuppetfiles {
Debugf("Syncing " + env)
Expand Down

0 comments on commit b9efde8

Please sign in to comment.