Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: milo/api/resp/build.go

Issue 2979283002: Add manifest links and hack to index on revision. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: milo/api/resp/build.go
diff --git a/milo/api/resp/build.go b/milo/api/resp/build.go
index 582f4df6234a72f20f08476d90631db6e8664fcc..4e5cc084de0376879b3da16b11ddf98be12ea8cf 100644
--- a/milo/api/resp/build.go
+++ b/milo/api/resp/build.go
@@ -18,9 +18,14 @@
package resp
import (
+ "encoding/hex"
"encoding/json"
"time"
+ "golang.org/x/net/context"
+
+ "github.com/luci/luci-go/common/logging"
+ "github.com/luci/luci-go/milo/common"
"github.com/luci/luci-go/milo/common/model"
)
@@ -278,7 +283,7 @@ func (comp *BuildComponent) toModelSummary() model.Summary {
}
// SummarizeTo summarizes the data into a given model.BuildSummary.
-func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) {
+func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) error {
bs.Summary = rb.Summary.toModelSummary()
if rb.Summary.Status == model.Running {
// Assume the last step is the current step.
@@ -288,13 +293,31 @@ func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) {
}
}
if rb.SourceStamp != nil {
- // TODO(hinoka): This should be full manifests, but lets just use single
- // revisions for now.
+ // TODO(hinoka, iannucci): This should be full manifests, but lets just use
+ // single revisions for now. HACKS!
if rb.SourceStamp.Revision != nil {
- bs.Manifests = append(bs.Manifests, model.ManifestLink{
- Name: "REVISION",
- ID: []byte(rb.SourceStamp.Revision.Label),
- })
+ revisionBytes, err := hex.DecodeString(rb.SourceStamp.Revision.Label)
+ if err != nil {
+ logging.WithError(err).Warningf(c, "bad revision (not hex-decodable)")
Ryan Tseng 2017/07/19 00:29:38 return here, forgo the else.
iannucci 2017/07/19 00:38:16 no, I actually want the rest of the function here
Ryan Tseng 2017/07/19 00:45:55 oh merp i forgot the stuff before ::wishes there w
+ } else {
+ bs.Manifests = append(bs.Manifests, model.ManifestLink{
+ Name: "REVISION",
+ ID: []byte(rb.SourceStamp.Revision.Label),
+ })
+ projs, err := common.GetAllProjects(c)
Ryan Tseng 2017/07/19 00:29:38 just make a common.GetConsolesForBuilder(c)
iannucci 2017/07/19 00:38:16 Done.
+ if err != nil {
+ return err
+ }
+ for _, p := range projs {
+ for _, cons := range p.Consoles {
+ for _, b := range cons.Builders {
+ if b.Name == bs.BuilderID {
+ bs.AddManifestRevisionIndex(cons.Name, "REVISION", revisionBytes)
+ }
+ }
+ }
+ }
+ }
}
if rb.SourceStamp.Changelist != nil {
bs.Patches = append(bs.Patches, model.PatchInfo{
@@ -303,4 +326,5 @@ func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) {
})
}
}
+ return nil
}

Powered by Google App Engine
This is Rietveld 408576698