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

Unified Diff: milo/common/model/build_summary.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: more changes 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 side-by-side diff with in-line comments
Download patch
Index: milo/common/model/build_summary.go
diff --git a/milo/common/model/build_summary.go b/milo/common/model/build_summary.go
index ac7f09dd2a5d60498682eb9dfe7baf21149f7ecb..2ffca30a43327dff90d7b73ba22a0f0c8c14937e 100644
--- a/milo/common/model/build_summary.go
+++ b/milo/common/model/build_summary.go
@@ -64,30 +64,53 @@ type BuildSummary struct {
// Typically there will only be one patch associated with a build.
Patches []PatchInfo
- // ManifestRevisionIndex has a single entry for each
+ // ManifestKey has a single entry for each
// 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode('hex')
- // which matched for this build. ++ is cmpbin concatenation.
+ // which matched for this build. This is used to index this BuildSummary as
+ // the row for any consoles that it shows up in that use the
+ // Manifest/RepoURL/Revision indexing scheme.
+ //
+ // (++ is cmpbin concatenation)
//
// Example:
// 0 ++ "chromium" ++ "main" ++ "UNPATCHED" ++ "https://.../src.git" ++ deadbeef
//
// The list of interested consoles is compiled at build summarization time.
- ManifestRevisionIndex [][]byte
+ ManifestKey [][]byte
Ryan Tseng 2017/07/20 00:36:25 ManifestKeys Consider type ManifestKey []byte, so
iannucci 2017/07/20 00:43:59 Done.
}
-// AddManifestRevisionIndex adds a new entry to ManifestRevisionIndex.
+// AddManifestKey adds a new entry to ManifestKey.
//
// `revision` should be the hex-decoded git revision.
//
-// It's up to the caller to ensure that entries in ManifestRevisionIndex aren't
+// It's up to the caller to ensure that entries in ManifestKey aren't
// duplicated.
-func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, repoURL string, revision []byte) {
+func (bs *BuildSummary) AddManifestKey(project, console, manifest, repoURL string, revision []byte) {
+ bs.ManifestKey = append(bs.ManifestKey,
+ NewPartialManifestKey(project, console, manifest, repoURL).AddRevision(revision))
+}
+
+// PartialManifestKey is an incomplete ManifestKey key which can be made
+// complete by calling AddRevision.
+type PartialManifestKey []byte
+
+// AddRevision appends a git revision (as bytes) to the PartialManifestKey,
+// returning a full index value for BuildSummary.ManifestKey.
+func (p PartialManifestKey) AddRevision(revision []byte) []byte {
+ var buf bytes.Buffer
+ buf.Write(p)
+ cmpbin.WriteBytes(&buf, revision)
+ return buf.Bytes()
+}
+
+// NewPartialManifestKey generates a ManifestKey prefix corresponding to
+// the given parameters.
+func NewPartialManifestKey(project, console, manifest, repoURL string) PartialManifestKey {
var buf bytes.Buffer
cmpbin.WriteUint(&buf, 0) // version
cmpbin.WriteString(&buf, project)
cmpbin.WriteString(&buf, console)
cmpbin.WriteString(&buf, manifest)
cmpbin.WriteString(&buf, repoURL)
- cmpbin.WriteBytes(&buf, revision)
- bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex, buf.Bytes())
+ return PartialManifestKey(buf.Bytes())
}
« no previous file with comments | « milo/buildsource/swarming/expectations/build-gerrit.json ('k') | milo/frontend/appengine/templates/pages/console.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698