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