summaryrefslogtreecommitdiff
path: root/misc/dashboard/builder/http.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
commit50104cc32a498f7517a51c8dc93106c51c7a54b4 (patch)
tree47af80be259cc7c45d0eaec7d42e61fa38c8e4fb /misc/dashboard/builder/http.go
parentc072558b90f1bbedc2022b0f30c8b1ac4712538e (diff)
downloadgolang-50104cc32a498f7517a51c8dc93106c51c7a54b4.tar.gz
Imported Upstream version 2011.03.07.1upstream/2011.03.07.1
Diffstat (limited to 'misc/dashboard/builder/http.go')
-rw-r--r--misc/dashboard/builder/http.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/misc/dashboard/builder/http.go b/misc/dashboard/builder/http.go
index 02f281061..dba19ba8f 100644
--- a/misc/dashboard/builder/http.go
+++ b/misc/dashboard/builder/http.go
@@ -1,3 +1,7 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package main
import (
@@ -6,8 +10,11 @@ import (
"encoding/binary"
"fmt"
"http"
+ "json"
+ "log"
"os"
"regexp"
+ "strconv"
)
// getHighWater returns the current highwater revision hash for this builder
@@ -63,7 +70,46 @@ func (b *Builder) recordBenchmarks(benchLog string, c Commit) os.Error {
})
}
+// getPackages fetches a list of package paths from the dashboard
+func getPackages() (pkgs []string, err os.Error) {
+ r, _, err := http.Get(fmt.Sprintf("http://%v/package?fmt=json", *dashboard))
+ if err != nil {
+ return
+ }
+ defer r.Body.Close()
+ d := json.NewDecoder(r.Body)
+ var resp struct {
+ Packages []struct {
+ Path string
+ }
+ }
+ if err = d.Decode(&resp); err != nil {
+ return
+ }
+ for _, p := range resp.Packages {
+ pkgs = append(pkgs, p.Path)
+ }
+ return
+}
+
+// updatePackage sends package build results and info to the dashboard
+func (b *Builder) updatePackage(pkg string, state bool, buildLog, info string, c Commit) os.Error {
+ args := map[string]string{
+ "builder": b.name,
+ "key": b.key,
+ "path": pkg,
+ "state": strconv.Btoa(state),
+ "log": buildLog,
+ "info": info,
+ "go_rev": strconv.Itoa(c.num),
+ }
+ return httpCommand("package", args)
+}
+
func httpCommand(cmd string, args map[string]string) os.Error {
+ if *verbose {
+ log.Println("httpCommand", cmd, args)
+ }
url := fmt.Sprintf("http://%v/%v", *dashboard, cmd)
_, err := http.PostForm(url, args)
return err