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

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

Issue 2964143002: Buildbucket: Save buildbucket build info and summary on pubsub push (Closed)
Patch Set: nits 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
« no previous file with comments | « no previous file | milo/buildsource/buildbucket/pubsub.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/api/resp/build.go
diff --git a/milo/api/resp/build.go b/milo/api/resp/build.go
index 1fc2a401632fc7fed16e20e2cc87843722d85eb3..9427b8101ff440a904763884bf27fde83cb60408 100644
--- a/milo/api/resp/build.go
+++ b/milo/api/resp/build.go
@@ -257,3 +257,40 @@ type Link struct {
func NewLink(label, url string) *Link {
return &Link{Link: model.Link{Label: label, URL: url}}
}
+
+func (comp *BuildComponent) toModelSummary() model.Summary {
+ return model.Summary{
+ Status: comp.Status,
+ Start: comp.Started,
+ End: comp.Finished,
+ Text: comp.Text,
+ }
+}
+
+// SummarizeTo summarizes the data into a given model.BuildSummary.
+func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) {
+ bs.Summary = rb.Summary.toModelSummary()
+ if rb.Summary.Status == model.Running {
+ // Assume the last step is the current step.
+ if len(rb.Components) > 0 {
+ cs := rb.Components[len(rb.Components)-1]
+ bs.CurrentStep = cs.toModelSummary()
+ }
+ }
+ if rb.SourceStamp != nil {
+ // TODO(hinoka): This should be full manifests, but lets just use single
+ // revisions for now.
+ if rb.SourceStamp.Revision != nil {
+ bs.Manifests = append(bs.Manifests, model.ManifestLink{
+ Name: "REVISION",
+ ID: []byte(rb.SourceStamp.Revision.Label),
+ })
+ }
+ if rb.SourceStamp.Changelist != nil {
+ bs.Patches = append(bs.Patches, model.PatchInfo{
+ Link: rb.SourceStamp.Changelist.Link,
+ AuthorEmail: rb.SourceStamp.AuthorEmail,
+ })
+ }
+ }
+}
« no previous file with comments | « no previous file | milo/buildsource/buildbucket/pubsub.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698