Chromium Code Reviews| Index: milo/buildsource/buildbucket/struct.go |
| diff --git a/milo/buildsource/buildbucket/struct.go b/milo/buildsource/buildbucket/struct.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c3063f4eaed1b0a791bca73884abf174eabdb59 |
| --- /dev/null |
| +++ b/milo/buildsource/buildbucket/struct.go |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2017 The LUCI Authors. All rights reserved. |
| +// Use of this source code is governed under the Apache License, Version 2.0 |
| +// that can be found in the LICENSE file. |
| + |
| +package buildbucket |
| + |
| +import ( |
| + "encoding/json" |
| + "fmt" |
| + "time" |
| + |
| + bucketApi "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1" |
| + "github.com/luci/luci-go/milo/api/resp" |
| +) |
| + |
| +type buildEntry struct { |
| + // key is formulated via <project ID>:<build ID>. From PubSub, project ID |
| + // is determined via the topic name. |
| + key string `gae:$id` |
| + |
| + // buildData is the json marshalled form of |
| + // a bucketApi.ApiCommonBuildMessage message. |
| + buildbucketData []byte `gae:,noindex` |
|
Ryan Tseng
2017/07/11 00:04:41
This would be useful as a broken out as a native s
|
| + |
| + // respBuild is the resp.MiloBuild representation of the build. |
| + respBuild *resp.MiloBuild `gae:,noindex` |
| + |
| + // project is the luci project name of the build. |
| + project string |
| + |
| + // created is the time when this build entry was first created. |
| + created time.Time |
| + |
| + // last is the time when this build entry was last modified. |
| + modified time.Time |
| +} |
| + |
| +// buildEntryKey returns the key for a build entry given a hostname and build ID. |
| +func buildEntryKey(host string, buildID int64) string { |
| + return fmt.Sprintf("%s:%d", host, buildID) |
| +} |
| + |
| +func (b *buildEntry) getBuild() (*bucketApi.ApiCommonBuildMessage, error) { |
| + msg := bucketApi.ApiCommonBuildMessage{} |
| + err := json.Unmarshal(b.buildbucketData, &msg) |
| + return &msg, err |
| +} |