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

Side by Side Diff: milo/appengine/buildbot/structs.go

Issue 2944633003: [milo] Add BuildSummary and common models. (Closed)
Patch Set: add comments Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « milo/appengine/buildbot/master.go ('k') | milo/appengine/buildbucket/buckets.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/gzip" 9 "compress/gzip"
10 "encoding/json" 10 "encoding/json"
11 "fmt" 11 "fmt"
12 "io/ioutil" 12 "io/ioutil"
13 "strconv" 13 "strconv"
14 14
15 "github.com/luci/gae/service/datastore" 15 "github.com/luci/gae/service/datastore"
16 "github.com/luci/luci-go/milo/api/resp" 16 "github.com/luci/luci-go/milo/api/resp"
17 "github.com/luci/luci-go/milo/appengine/common/model"
17 ) 18 )
18 19
19 // This file contains all of the structs that define buildbot json endpoints. 20 // This file contains all of the structs that define buildbot json endpoints.
20 // This is primarily used for unmarshalling buildbot master and build json. 21 // This is primarily used for unmarshalling buildbot master and build json.
21 // json.UnmarshalJSON can directly unmarshal buildbot jsons into these structs. 22 // json.UnmarshalJSON can directly unmarshal buildbot jsons into these structs.
22 // Many of the structs were initially built using https://mholt.github.io/json-t o-go/ 23 // Many of the structs were initially built using https://mholt.github.io/json-t o-go/
23 24
24 // buildbotStep represents a single step in a buildbot build. 25 // buildbotStep represents a single step in a buildbot build.
25 type buildbotStep struct { 26 type buildbotStep struct {
26 // We actually don't care about ETA. This is represented as a string if 27 // We actually don't care about ETA. This is represented as a string if
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 Repository string `json:"repository"` 59 Repository string `json:"repository"`
59 Revision string `json:"revision"` 60 Revision string `json:"revision"`
60 } 61 }
61 62
62 type buildbotLinkAlias struct { 63 type buildbotLinkAlias struct {
63 URL string `json:"url"` 64 URL string `json:"url"`
64 Text string `json:"text"` 65 Text string `json:"text"`
65 } 66 }
66 67
67 func (a *buildbotLinkAlias) toLink() *resp.Link { 68 func (a *buildbotLinkAlias) toLink() *resp.Link {
68 » return &resp.Link{ 69 » return resp.NewLink(a.Text, a.URL)
69 » » Label: a.Text,
70 » » URL: a.URL,
71 » }
72 } 70 }
73 71
74 type buildbotProperty struct { 72 type buildbotProperty struct {
75 Name string 73 Name string
76 Value interface{} 74 Value interface{}
77 Source string 75 Source string
78 } 76 }
79 77
80 func (p *buildbotProperty) MarshalJSON() ([]byte, error) { 78 func (p *buildbotProperty) MarshalJSON() ([]byte, error) {
81 return json.Marshal([]interface{}{p.Name, p.Value, p.Source}) 79 return json.Marshal([]interface{}{p.Name, p.Value, p.Source})
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Finished bool `json:"finished"` 137 Finished bool `json:"finished"`
140 // OS is a string representation of the OS the build ran on. This is 138 // OS is a string representation of the OS the build ran on. This is
141 // derived best-effort from the slave information in the master JSON. 139 // derived best-effort from the slave information in the master JSON.
142 // This information is injected into the buildbot builds via puppet, and 140 // This information is injected into the buildbot builds via puppet, and
143 // comes as Family + Version. Family is (windows, Darwin, Debian), whil e 141 // comes as Family + Version. Family is (windows, Darwin, Debian), whil e
144 // Version is the version of the OS, such as (XP, 7, 10) for windows. 142 // Version is the version of the OS, such as (XP, 7, 10) for windows.
145 OSFamily string `json:"osFamily"` 143 OSFamily string `json:"osFamily"`
146 OSVersion string `json:"osVersion"` 144 OSVersion string `json:"osVersion"`
147 } 145 }
148 146
149 func (b *buildbotBuild) toStatus() resp.Status { 147 func (b *buildbotBuild) toStatus() model.Status {
150 » var result resp.Status 148 » var result model.Status
151 if b.Currentstep != nil { 149 if b.Currentstep != nil {
152 » » result = resp.Running 150 » » result = model.Running
153 } else { 151 } else {
154 result = result2Status(b.Results) 152 result = result2Status(b.Results)
155 } 153 }
156 return result 154 return result
157 } 155 }
158 156
159 var _ datastore.PropertyLoadSaver = (*buildbotBuild)(nil) 157 var _ datastore.PropertyLoadSaver = (*buildbotBuild)(nil)
160 var _ datastore.MetaGetterSetter = (*buildbotBuild)(nil) 158 var _ datastore.MetaGetterSetter = (*buildbotBuild)(nil)
161 159
162 // getID is a helper function that returns the datastore key for a given 160 // getID is a helper function that returns the datastore key for a given
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 PendingBuilds int `json:"pending_builds"` 430 PendingBuilds int `json:"pending_builds"`
433 State string `json:"state"` 431 State string `json:"state"`
434 TotalSlaves int `json:"total_slaves"` 432 TotalSlaves int `json:"total_slaves"`
435 } `json:"builders"` 433 } `json:"builders"`
436 ServerUptime float64 `json:"server_uptime"` 434 ServerUptime float64 `json:"server_uptime"`
437 } `json:"varz"` 435 } `json:"varz"`
438 436
439 // This is injected by the pubsub publisher on the buildbot side. 437 // This is injected by the pubsub publisher on the buildbot side.
440 Name string `json:"name"` 438 Name string `json:"name"`
441 } 439 }
OLDNEW
« no previous file with comments | « milo/appengine/buildbot/master.go ('k') | milo/appengine/buildbucket/buckets.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698