Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 Project string `json:"project"` | 327 Project string `json:"project"` |
| 328 Properties [][]interface{} `json:"properties"` | 328 Properties [][]interface{} `json:"properties"` |
| 329 Repository string `json:"repository"` | 329 Repository string `json:"repository"` |
| 330 Rev string `json:"rev"` | 330 Rev string `json:"rev"` |
| 331 Revision string `json:"revision"` | 331 Revision string `json:"revision"` |
| 332 Revlink string `json:"revlink"` | 332 Revlink string `json:"revlink"` |
| 333 When int `json:"when"` | 333 When int `json:"when"` |
| 334 Who string `json:"who"` | 334 Who string `json:"who"` |
| 335 } | 335 } |
| 336 | 336 |
| 337 func (bc *buildbotChange) GetFiles() []string { | |
| 338 files := make([]string, len(bc.Files)) | |
| 339 for i, f := range bc.Files { | |
| 340 // Buildbot stores files both as a string, or as a dict with a s ingle entry | |
| 341 // named "name". It doesn't matter to us what the type is, but we need | |
| 342 // to reflect on the type anyways. | |
| 343 if fn, ok := f.(string); ok { | |
|
nodir
2017/04/19 18:37:48
i think a type-switch would be cleaner here
hinoka
2017/04/20 22:09:43
Done.
| |
| 344 files[i] = fn | |
| 345 } else if fn, ok := f.(map[string]interface{}); ok { | |
| 346 if name, ok := fn["name"]; ok { | |
| 347 files[i] = fmt.Sprintf("%s", name) | |
| 348 } else { | |
| 349 files[i] = fmt.Sprintf("%#v", f) | |
|
nodir
2017/04/19 18:37:48
i think if a user sees such as string, they would
nodir
2017/04/20 03:24:08
I meant omitting
hinoka
2017/04/20 22:09:43
Done. It just omits it without logging because I
| |
| 350 } | |
| 351 } else { | |
| 352 files[i] = fmt.Sprintf("%#v", f) | |
| 353 } | |
| 354 } | |
| 355 return files | |
| 356 } | |
| 357 | |
| 337 // buildbotSlave describes a slave on a master from a master json, and also incl udes the | 358 // buildbotSlave describes a slave on a master from a master json, and also incl udes the |
| 338 // full builds of any currently running builds. | 359 // full builds of any currently running builds. |
| 339 type buildbotSlave struct { | 360 type buildbotSlave struct { |
| 340 // RecentBuilds is a map of builder name to a list of recent finished bu ild | 361 // RecentBuilds is a map of builder name to a list of recent finished bu ild |
| 341 // numbers on that builder. | 362 // numbers on that builder. |
| 342 RecentBuilds map[string][]int `json:"builders"` | 363 RecentBuilds map[string][]int `json:"builders"` |
| 343 Connected bool `json:"connected"` | 364 Connected bool `json:"connected"` |
| 344 Host string `json:"host"` | 365 Host string `json:"host"` |
| 345 Name string `json:"name"` | 366 Name string `json:"name"` |
| 346 Runningbuilds []*buildbotBuild `json:"runningBuilds"` | 367 Runningbuilds []*buildbotBuild `json:"runningBuilds"` |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 PendingBuilds int `json:"pending_builds"` | 435 PendingBuilds int `json:"pending_builds"` |
| 415 State string `json:"state"` | 436 State string `json:"state"` |
| 416 TotalSlaves int `json:"total_slaves"` | 437 TotalSlaves int `json:"total_slaves"` |
| 417 } `json:"builders"` | 438 } `json:"builders"` |
| 418 ServerUptime float64 `json:"server_uptime"` | 439 ServerUptime float64 `json:"server_uptime"` |
| 419 } `json:"varz"` | 440 } `json:"varz"` |
| 420 | 441 |
| 421 // This is injected by the pubsub publisher on the buildbot side. | 442 // This is injected by the pubsub publisher on the buildbot side. |
| 422 Name string `json:"name"` | 443 Name string `json:"name"` |
| 423 } | 444 } |
| OLD | NEW |