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

Side by Side Diff: milo/api/resp/build.go

Issue 2979283002: Add manifest links and hack to index on revision. (Closed)
Patch Set: actually upload 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 unified diff | Download patch
« no previous file with comments | « common/proto/milo/annotations.pb.go ('k') | milo/buildsource/buildbot/pubsub.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 //go:generate stringer -type=Verbosity 15 //go:generate stringer -type=Verbosity
16 //go:generate stringer -type=ComponentType 16 //go:generate stringer -type=ComponentType
17 17
18 package resp 18 package resp
19 19
20 import ( 20 import (
21 "encoding/hex"
21 "encoding/json" 22 "encoding/json"
22 "time" 23 "time"
23 24
25 "golang.org/x/net/context"
26
27 "github.com/luci/luci-go/common/logging"
28 "github.com/luci/luci-go/milo/common"
24 "github.com/luci/luci-go/milo/common/model" 29 "github.com/luci/luci-go/milo/common/model"
25 ) 30 )
26 31
27 // MiloBuild denotes a full renderable Milo build page. 32 // MiloBuild denotes a full renderable Milo build page.
28 type MiloBuild struct { 33 type MiloBuild struct {
29 // Summary is a top level summary of the page. 34 // Summary is a top level summary of the page.
30 Summary BuildComponent 35 Summary BuildComponent
31 36
32 // SourceStamp gives information about how the build came about. 37 // SourceStamp gives information about how the build came about.
33 SourceStamp *SourceStamp 38 SourceStamp *SourceStamp
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 func (comp *BuildComponent) toModelSummary() model.Summary { 276 func (comp *BuildComponent) toModelSummary() model.Summary {
272 return model.Summary{ 277 return model.Summary{
273 Status: comp.Status, 278 Status: comp.Status,
274 Start: comp.Started, 279 Start: comp.Started,
275 End: comp.Finished, 280 End: comp.Finished,
276 Text: comp.Text, 281 Text: comp.Text,
277 } 282 }
278 } 283 }
279 284
280 // SummarizeTo summarizes the data into a given model.BuildSummary. 285 // SummarizeTo summarizes the data into a given model.BuildSummary.
281 func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) { 286 func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) erro r {
282 bs.Summary = rb.Summary.toModelSummary() 287 bs.Summary = rb.Summary.toModelSummary()
283 if rb.Summary.Status == model.Running { 288 if rb.Summary.Status == model.Running {
284 // Assume the last step is the current step. 289 // Assume the last step is the current step.
285 if len(rb.Components) > 0 { 290 if len(rb.Components) > 0 {
286 cs := rb.Components[len(rb.Components)-1] 291 cs := rb.Components[len(rb.Components)-1]
287 bs.CurrentStep = cs.toModelSummary() 292 bs.CurrentStep = cs.toModelSummary()
288 } 293 }
289 } 294 }
290 if rb.SourceStamp != nil { 295 if rb.SourceStamp != nil {
291 » » // TODO(hinoka): This should be full manifests, but lets just us e single 296 » » // TODO(hinoka, iannucci): This should be full manifests, but le ts just use
292 » » // revisions for now. 297 » » // single revisions for now. HACKS!
293 if rb.SourceStamp.Revision != nil { 298 if rb.SourceStamp.Revision != nil {
294 » » » bs.Manifests = append(bs.Manifests, model.ManifestLink{ 299 » » » revisionBytes, err := hex.DecodeString(rb.SourceStamp.Re vision.Label)
295 » » » » Name: "REVISION", 300 » » » if err != nil {
296 » » » » ID: []byte(rb.SourceStamp.Revision.Label), 301 » » » » logging.WithError(err).Warningf(c, "bad revision (not hex-decodable)")
297 » » » }) 302 » » » } else {
303 » » » » bs.Manifests = append(bs.Manifests, model.Manife stLink{
304 » » » » » Name: "REVISION",
305 » » » » » ID: []byte(rb.SourceStamp.Revision.Lab el),
306 » » » » })
307 » » » » consoles, err := common.GetConsolesForBuilder(c, bs.BuilderID)
308 » » » » if err != nil {
309 » » » » » return err
310 » » » » }
311 » » » » for _, con := range consoles {
312 » » » » » // HACK(iannucci): Until we have real ma nifest support, console
313 » » » » » // definitions will specify their manife st as "REVISION", and we'll do
314 » » » » » // lookups with null URL fields.
315 » » » » » bs.AddManifestRevisionIndex(
316 » » » » » » con.ProjectID, con.Console.Name, "REVISION", "", revisionBytes)
317 » » » » }
318 » » » }
298 } 319 }
299 if rb.SourceStamp.Changelist != nil { 320 if rb.SourceStamp.Changelist != nil {
300 bs.Patches = append(bs.Patches, model.PatchInfo{ 321 bs.Patches = append(bs.Patches, model.PatchInfo{
301 Link: rb.SourceStamp.Changelist.Link, 322 Link: rb.SourceStamp.Changelist.Link,
302 AuthorEmail: rb.SourceStamp.AuthorEmail, 323 AuthorEmail: rb.SourceStamp.AuthorEmail,
303 }) 324 })
304 } 325 }
305 } 326 }
327 return nil
306 } 328 }
OLDNEW
« no previous file with comments | « common/proto/milo/annotations.pb.go ('k') | milo/buildsource/buildbot/pubsub.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698