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 type buildEntry struct { | |
| 17 // key is formulated via <project ID>:<build ID>. From PubSub, project ID | |
| 18 // is determined via the topic name. | |
| 19 key string `gae:$id` | |
| 20 | |
| 21 // buildData is the json marshalled form of | |
| 22 // a bucketApi.ApiCommonBuildMessage message. | |
| 23 buildbucketData []byte `gae:,noindex` | |
|
Ryan Tseng
2017/07/11 00:04:41
This would be useful as a broken out as a native s
| |
| 24 | |
| 25 // respBuild is the resp.MiloBuild representation of the build. | |
| 26 respBuild *resp.MiloBuild `gae:,noindex` | |
| 27 | |
| 28 // project is the luci project name of the build. | |
| 29 project string | |
| 30 | |
| 31 // created is the time when this build entry was first created. | |
| 32 created time.Time | |
| 33 | |
| 34 // last is the time when this build entry was last modified. | |
| 35 modified time.Time | |
| 36 } | |
| 37 | |
| 38 // buildEntryKey returns the key for a build entry given a hostname and build ID . | |
| 39 func buildEntryKey(host string, buildID int64) string { | |
| 40 return fmt.Sprintf("%s:%d", host, buildID) | |
| 41 } | |
| 42 | |
| 43 func (b *buildEntry) getBuild() (*bucketApi.ApiCommonBuildMessage, error) { | |
| 44 msg := bucketApi.ApiCommonBuildMessage{} | |
| 45 err := json.Unmarshal(b.buildbucketData, &msg) | |
| 46 return &msg, err | |
| 47 } | |
| OLD | NEW |