| 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 "encoding/json" | 8 "encoding/json" |
| 9 "errors" | 9 "errors" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 // parseProp returns a representation of v based off k, and a boolean to | 330 // parseProp returns a representation of v based off k, and a boolean to |
| 331 // specify whether or not to hide it altogether. | 331 // specify whether or not to hide it altogether. |
| 332 func parseProp(prop map[string]Prop, k string, v interface{}) (string, bool) { | 332 func parseProp(prop map[string]Prop, k string, v interface{}) (string, bool) { |
| 333 switch k { | 333 switch k { |
| 334 case "requestedAt": | 334 case "requestedAt": |
| 335 if vf, ok := v.(float64); ok { | 335 if vf, ok := v.(float64); ok { |
| 336 return time.Unix(int64(vf), 0).UTC().Format(time.RFC3339
), true | 336 return time.Unix(int64(vf), 0).UTC().Format(time.RFC3339
), true |
| 337 } | 337 } |
| 338 case "buildbucket": | |
| 339 var b map[string]interface{} | |
| 340 json.Unmarshal([]byte(v.(string)), &b) | |
| 341 if b["build"] == nil { | |
| 342 return "", false | |
| 343 } | |
| 344 build := b["build"].(map[string]interface{}) | |
| 345 id := build["id"] | |
| 346 if id == nil { | |
| 347 return "", false | |
| 348 } | |
| 349 return fmt.Sprintf("https://cr-buildbucket.appspot.com/b/%s", id
.(string)), true | |
| 350 case "issue": | 338 case "issue": |
| 351 if rv, ok := prop["rietveld"]; ok { | 339 if rv, ok := prop["rietveld"]; ok { |
| 352 rietveld := rv.Value.(string) | 340 rietveld := rv.Value.(string) |
| 353 // Issue could be a float, int, or string. | 341 // Issue could be a float, int, or string. |
| 354 switch v := v.(type) { | 342 switch v := v.(type) { |
| 355 case float64: | 343 case float64: |
| 356 return fmt.Sprintf("%s/%d", rietveld, int(v)), t
rue | 344 return fmt.Sprintf("%s/%d", rietveld, int(v)), t
rue |
| 357 default: // Probably int or string | 345 default: // Probably int or string |
| 358 return fmt.Sprintf("%s/%v", rietveld, v), true | 346 return fmt.Sprintf("%s/%v", rietveld, v), true |
| 359 } | 347 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 512 |
| 525 // TODO(hinoka): Do all fields concurrently. | 513 // TODO(hinoka): Do all fields concurrently. |
| 526 return &resp.MiloBuild{ | 514 return &resp.MiloBuild{ |
| 527 SourceStamp: sourcestamp(c, b), | 515 SourceStamp: sourcestamp(c, b), |
| 528 Summary: summary(c, b), | 516 Summary: summary(c, b), |
| 529 Components: components(b), | 517 Components: components(b), |
| 530 PropertyGroup: properties(b), | 518 PropertyGroup: properties(b), |
| 531 Blame: blame(b), | 519 Blame: blame(b), |
| 532 }, nil | 520 }, nil |
| 533 } | 521 } |
| OLD | NEW |