func checkTryBuildDeps() error { if !hasStorageScope() { return errors.New("coordinator's GCE instance lacks the storage service scope") } wr := storage.NewWriter(serviceCtx, buildLogBucket(), "hello.txt") fmt.Fprintf(wr, "Hello, world! Coordinator start-up at %v", time.Now()) if err := wr.Close(); err != nil { return fmt.Errorf("test write of a GCS object to bucket %q failed: %v", buildLogBucket(), err) } gobotPass, err := metadata.ProjectAttributeValue("gobot-password") if err != nil { return fmt.Errorf("failed to get project metadata 'gobot-password': %v", err) } gerritClient = gerrit.NewClient("https://go-review.googlesource.com", gerrit.BasicAuth("git-gobot.golang.org", strings.TrimSpace(string(gobotPass)))) return nil }
func main() { gobotPass, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), "keys", "gobot-golang-org.cookie")) if err != nil { log.Fatal(err) } c := gerrit.NewClient("https://go-review.googlesource.com", gerrit.BasicAuth("git-gobot.golang.org", strings.TrimSpace(string(gobotPass)))) cl, err := c.QueryChanges("label:Run-TryBot=1 label:TryBot-Result=0 project:go status:open", gerrit.QueryChangesOpt{ Fields: []string{"CURRENT_REVISION"}, }) if err != nil { log.Fatal(err) } v, _ := json.MarshalIndent(cl, "", " ") os.Stdout.Write(v) log.Printf("SetReview = %v", c.SetReview("I2383397c056a9ffe174ac7c2c6e5bb334406fbf9", "current", gerrit.ReviewInput{ Message: "test test", Labels: map[string]int{ "TryBot-Result": 0, }, })) }