mirror of
https://github.com/kennethreitz/herald.git
synced 2026-06-05 23:00:19 +00:00
@@ -12,10 +12,13 @@ func main() {
|
||||
for {
|
||||
|
||||
// Do the buldpack thing.
|
||||
herald.DownloadBuildpacks()
|
||||
buildpacks := herald.GetBuildpacks()
|
||||
for _, bp := range(buildpacks) {
|
||||
log.Print(bp.Download())
|
||||
}
|
||||
|
||||
log.Print("Sleeping for 5 minutes…")
|
||||
|
||||
|
||||
// Sleep for five minutes.
|
||||
time.Sleep(5*time.Minute)
|
||||
|
||||
|
||||
@@ -10,35 +10,56 @@ import "log"
|
||||
const BP_TARBALL_TEMPLATE = "https://github.com/heroku/heroku-buildpack-%s/archive/master.zip"
|
||||
var BUILDPACKS = []string { "python", "php", "nodejs" }
|
||||
|
||||
func getBuildpackZipballs() []string {
|
||||
collected := []string{}
|
||||
|
||||
for _, bp := range(BUILDPACKS) {
|
||||
// Add comment here.
|
||||
collected = append(collected, fmt.Sprintf(BP_TARBALL_TEMPLATE, bp))
|
||||
}
|
||||
|
||||
return collected
|
||||
|
||||
type Version string
|
||||
|
||||
type Buildpack struct{
|
||||
Versions []Version
|
||||
Tarball string
|
||||
Path string
|
||||
// ExecutablePath string
|
||||
Name string
|
||||
}
|
||||
|
||||
func DownloadBuildpacks() {
|
||||
|
||||
// create temp directory
|
||||
// use 'fake' for now
|
||||
target, err := ioutil.TempDir("", "buildpacks")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
func (b Buildpack) ZipballURI() string {
|
||||
return fmt.Sprintf(BP_TARBALL_TEMPLATE, b.Name)
|
||||
}
|
||||
|
||||
func (b Buildpack) Download() string {
|
||||
target, _ := ioutil.TempDir("", "buildpacks")
|
||||
|
||||
log.Printf("Downloading '%s'…", b.Name)
|
||||
|
||||
getter.Get(target, b.ZipballURI())
|
||||
|
||||
return target
|
||||
|
||||
// Download and unpack each Zipball from GitHub.
|
||||
for _, tb := range(getBuildpackZipballs()) {
|
||||
log.Printf("Downloading '%s' to '%s'…", tb, target)
|
||||
getter.Get(target, tb)
|
||||
}
|
||||
|
||||
func NewBuildpack(name string) Buildpack {
|
||||
return Buildpack{
|
||||
// Path: nil,
|
||||
// ExecutablePath: path + "/bin/execute",
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func GetBuildpacks() []Buildpack {
|
||||
// Download and unpack each Zipball from GitHub.
|
||||
|
||||
buildpacks := []Buildpack{}
|
||||
for _, bp := range(BUILDPACKS) {
|
||||
// log.Printf("Downloading '%s'…", bp)
|
||||
|
||||
// err := getter.Get(target, tb)
|
||||
// if err != nil {
|
||||
// return err
|
||||
buildpacks = append(buildpacks, NewBuildpack(bp))
|
||||
}
|
||||
|
||||
return buildpacks
|
||||
}
|
||||
|
||||
// func ExecutesBuildpacks() {
|
||||
|
||||
// glob('*/updater/detect'
|
||||
|
||||
Reference in New Issue
Block a user