| 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 "fmt" | 9 "fmt" |
| 10 "io/ioutil" | 10 "io/ioutil" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 // parseProp returns a representation of v based off k, and a boolean to | 294 // parseProp returns a representation of v based off k, and a boolean to |
| 295 // specify whether or not to hide it altogether. | 295 // specify whether or not to hide it altogether. |
| 296 func parseProp(prop map[string]Prop, k string, v interface{}) (string, bool) { | 296 func parseProp(prop map[string]Prop, k string, v interface{}) (string, bool) { |
| 297 switch k { | 297 switch k { |
| 298 case "requestedAt": | 298 case "requestedAt": |
| 299 if vf, ok := v.(float64); ok { | 299 if vf, ok := v.(float64); ok { |
| 300 return time.Unix(int64(vf), 0).UTC().Format(time.RFC3339
), true | 300 return time.Unix(int64(vf), 0).UTC().Format(time.RFC3339
), true |
| 301 } | 301 } |
| 302 case "buildbucket": | |
| 303 var b map[string]interface{} | |
| 304 json.Unmarshal([]byte(v.(string)), &b) | |
| 305 if b["build"] == nil { | |
| 306 return "", false | |
| 307 } | |
| 308 build := b["build"].(map[string]interface{}) | |
| 309 id := build["id"] | |
| 310 if id == nil { | |
| 311 return "", false | |
| 312 } | |
| 313 return fmt.Sprintf("https://cr-buildbucket.appspot.com/b/%s", id
.(string)), true | |
| 314 case "issue": | 302 case "issue": |
| 315 if rv, ok := prop["rietveld"]; ok { | 303 if rv, ok := prop["rietveld"]; ok { |
| 316 rietveld := rv.Value.(string) | 304 rietveld := rv.Value.(string) |
| 317 // Issue could be a float, int, or string. | 305 // Issue could be a float, int, or string. |
| 318 switch v := v.(type) { | 306 switch v := v.(type) { |
| 319 case float64: | 307 case float64: |
| 320 return fmt.Sprintf("%s/%d", rietveld, int(v)), t
rue | 308 return fmt.Sprintf("%s/%d", rietveld, int(v)), t
rue |
| 321 default: // Probably int or string | 309 default: // Probably int or string |
| 322 return fmt.Sprintf("%s/%v", rietveld, v), true | 310 return fmt.Sprintf("%s/%v", rietveld, v), true |
| 323 } | 311 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 476 |
| 489 // TODO(hinoka): Do all fields concurrently. | 477 // TODO(hinoka): Do all fields concurrently. |
| 490 return &resp.MiloBuild{ | 478 return &resp.MiloBuild{ |
| 491 SourceStamp: sourcestamp(c, b), | 479 SourceStamp: sourcestamp(c, b), |
| 492 Summary: summary(c, b), | 480 Summary: summary(c, b), |
| 493 Components: components(b), | 481 Components: components(b), |
| 494 PropertyGroup: properties(b), | 482 PropertyGroup: properties(b), |
| 495 Blame: blame(b), | 483 Blame: blame(b), |
| 496 }, nil | 484 }, nil |
| 497 } | 485 } |
| OLD | NEW |