Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package buildbucket | |
| 6 | |
| 7 import ( | |
| 8 "encoding/json" | |
| 9 "fmt" | |
| 10 "time" | |
| 11 | |
| 12 bucketApi "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1 " | |
| 13 "github.com/luci/luci-go/milo/api/resp" | |
| 14 ) | |
| 15 | |
| 16 // buildEntry is a full buildbucket build along with its full resp rendering | |
| 17 // at the time of modification. This is a parent of a BuildSummary. | |
| 18 type buildEntry struct { | |
| 19 // key is formulated via <project ID>:<build ID>. From PubSub, project ID | |
| 20 // is determined via the topic name. | |
| 21 key string `gae:$id` | |
| 22 | |
| 23 // buildData is the json marshalled form of | |
| 24 // a bucketApi.ApiCommonBuildMessage message. | |
| 25 buildbucketData []byte `gae:,noindex` | |
| 26 | |
| 27 // respBuild is the resp.MiloBuild representation of the build. | |
| 28 respBuild *resp.MiloBuild `gae:,noindex` | |
|
iannucci
2017/07/11 21:51:20
this doesn't have any nested stuff? Note that if t
Ryan Tseng
2017/07/11 23:09:22
It's actually not nested, not even nested builds a
| |
| 29 | |
| 30 // project is the luci project name of the build. | |
| 31 project string | |
| 32 | |
| 33 // created is the time when this build entry was first created. | |
| 34 created time.Time | |
| 35 | |
| 36 // last is the time when this build entry was last modified. | |
| 37 modified time.Time | |
| 38 } | |
| 39 | |
| 40 // buildEntryKey returns the key for a build entry given a hostname and build ID . | |
| 41 func buildEntryKey(host string, buildID int64) string { | |
| 42 return fmt.Sprintf("%s:%d", host, buildID) | |
| 43 } | |
| 44 | |
| 45 func (b *buildEntry) getBuild() (*bucketApi.ApiCommonBuildMessage, error) { | |
| 46 msg := bucketApi.ApiCommonBuildMessage{} | |
| 47 err := json.Unmarshal(b.buildbucketData, &msg) | |
| 48 return &msg, err | |
| 49 } | |
| OLD | NEW |