Files
herald/cmd/version-scraper/main.go
T
kennethreitz 24f8ca6b3a connecting to redis
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-12-13 09:28:06 -05:00

69 lines
1.4 KiB
Go

package main
import "github.com/heroku/herald"
import "github.com/fatih/color"
import "time"
import "log"
func main() {
// Redis stuff.
redis := herald.RedisConnect()
_ = redis
// Color Stuff.
color.NoColor = false
red := color.New(color.FgRed).SprintFunc()
magenta := color.New(color.FgMagenta).SprintFunc()
green := color.New(color.FgGreen).SprintFunc()
yellow := color.New(color.FgYellow).SprintFunc()
bold := color.New(color.Bold, color.FgWhite).SprintFunc()
for {
// Get a list of the buildpacks (as types).
buildpacks := herald.GetBuildpacks()
// Iterate over them.
for _, bp := range(buildpacks) {
// Download and extract each Buildpack.
log.Printf(bold("Downloading '%s'…"), red(bp.Name))
path := bp.Download()
log.Printf("Buildpack '%s' downloaded to '%s'!", red(bp), green(path))
// Find all version executables for the given buildpack.
executables := bp.FindVersionScripts()
for _, exe := range(executables) {
log.Printf(yellow("Executing '%s:%s' script…"), red(bp), magenta(exe))
// TODO: Ensure chmod for the executable.
exe.EnsureExecutable()
// Execute the executable, print the results.
results := exe.Execute()
// for _, result := range(results) {
// }
// Log results.
log.Printf("%s:%s results: %s", red(bp), magenta(exe), results)
}
}
log.Print(bold("Sleeping for 10 minutes…"))
// Sleep for ten minutes.
time.Sleep(10*time.Minute)
}
}