| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 "bytes" | |
| 9 "strconv" | |
| 10 ) | |
| 11 | |
| 12 // This file is about buildbucket build params in the format supported by | |
| 13 // Buildbot. | |
| 14 | |
| 15 // properties is well-established build properties. | |
| 16 type properties struct { | |
| 17 PatchStorage string `json:"patch_storage"` // e.g. "rietveld", "gerrit" | |
| 18 | |
| 19 RietveldURL string `json:"rietveld"` // e.g. "https://codereview.chromiu
m.org" | |
| 20 Issue number `json:"issue"` // e.g. 2127373005 | |
| 21 PatchSet number `json:"patchset"` // e.g. 40001 for rietveld | |
| 22 | |
| 23 GerritPatchURL string `json:"patch_gerrit_url"` // e.g. "h
ttps://chromium-review.googlesource.com" | |
| 24 GerritPatchIssue int `json:"patch_issue"` // e.g. 35
8171 | |
| 25 GerritPatchSet number `json:"patch_set"` // e.g. 1 | |
| 26 GerritPatchProject string `json:"patch_project"` // e.g. "i
nfra/infra" | |
| 27 GerritPatchRepositoryURL string `json:"patch_repository_url"` // e.g. ht
tps://chromium.googlesource.com/infra/infra | |
| 28 | |
| 29 Revision string `json:"revision"` // e.g. "0b04861933367c62630751702
c84fd64bc3caf6f" | |
| 30 BlameList []string `json:"blamelist"` // e.g. ["someone@chromium.org"] | |
| 31 | |
| 32 // Fields below are present only in ResultDetails. | |
| 33 | |
| 34 GotRevision string `json:"got_revision"` // e.g. "0b04861933367c62630751
702c84fd64bc3caf6f" | |
| 35 BuildNumber int `json:"buildnumber"` // e.g. 3021 | |
| 36 } | |
| 37 | |
| 38 // number is an integer that supports JSON unmarshalling from a string. | |
| 39 type number int | |
| 40 | |
| 41 // UnmarshalJSON parses data as an integer, whether data is a number or string. | |
| 42 func (n *number) UnmarshalJSON(data []byte) error { | |
| 43 data = bytes.Trim(data, `"`) | |
| 44 num, err := strconv.Atoi(string(data)) | |
| 45 if err == nil { | |
| 46 *n = number(num) | |
| 47 } | |
| 48 return err | |
| 49 } | |
| 50 | |
| 51 // change is used in "changes" buildbucket parameters; supported by buildbot | |
| 52 // See https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/m
aster/buildbucket/README.md#Build-parameters | |
| 53 type change struct { | |
| 54 Author struct{ Email string } | |
| 55 } | |
| 56 | |
| 57 // buildParameters is contents of "parameters_json" buildbucket build field | |
| 58 // in the format supported by Buildbot, see | |
| 59 // // See https://chromium.googlesource.com/chromium/tools/build/+/master/script
s/master/buildbucket/README.md#Build-parameters | |
| 60 // | |
| 61 // Buildbucket is not aware of this format, but majority of chrome-infra is. | |
| 62 type buildParameters struct { | |
| 63 BuilderName string `json:"builder_name"` | |
| 64 Properties properties | |
| 65 Changes []change | |
| 66 } | |
| 67 | |
| 68 // resultDetails is contents of "result_details_json" buildbucket build field | |
| 69 // in the format supported by Buildbot. | |
| 70 type resultDetails struct { | |
| 71 Properties properties | |
| 72 } | |
| OLD | NEW |