| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 buildbucket | 5 package buildbucket |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "fmt" | 9 "fmt" |
| 10 "net/http" | 10 "net/http" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 BuildKey: key, | 157 BuildKey: key, |
| 158 BuilderID: fmt.Sprintf("buildbucket/%s/%s", build.Bucket, builde
rName), | 158 BuilderID: fmt.Sprintf("buildbucket/%s/%s", build.Bucket, builde
rName), |
| 159 Created: parseTimestamp(build.CreatedTs), | 159 Created: parseTimestamp(build.CreatedTs), |
| 160 Summary: model.Summary{ | 160 Summary: model.Summary{ |
| 161 Status: status, | 161 Status: status, |
| 162 Start: parseTimestamp(build.StartedTs), | 162 Start: parseTimestamp(build.StartedTs), |
| 163 }, | 163 }, |
| 164 } | 164 } |
| 165 if entry.respBuild != nil { | 165 if entry.respBuild != nil { |
| 166 // Add info from the respBuild into the build summary if we have
the data. | 166 // Add info from the respBuild into the build summary if we have
the data. |
| 167 » » entry.respBuild.SummarizeTo(&bs) | 167 » » if err := entry.respBuild.SummarizeTo(c, &bs); err != nil { |
| 168 » » » return err |
| 169 » » } |
| 168 } | 170 } |
| 169 logging.Debugf(c, "Created build summary: %#v", bs) | 171 logging.Debugf(c, "Created build summary: %#v", bs) |
| 170 // Make datastore flakes transient errors | 172 // Make datastore flakes transient errors |
| 171 return transient.Tag.Apply(datastore.Put(c, &bs)) | 173 return transient.Tag.Apply(datastore.Put(c, &bs)) |
| 172 } | 174 } |
| 173 | 175 |
| 174 func handlePubSubBuild(c context.Context, data *psMsg) error { | 176 func handlePubSubBuild(c context.Context, data *psMsg) error { |
| 175 host := data.Hostname | 177 host := data.Hostname |
| 176 build := &data.Build | 178 build := &data.Build |
| 177 // We only care about the "builder_name" key from the parameter. | 179 // We only care about the "builder_name" key from the parameter. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 logging.WithError(err).Errorf(c, "could not parse pubsub message
string") | 230 logging.WithError(err).Errorf(c, "could not parse pubsub message
string") |
| 229 return err | 231 return err |
| 230 } | 232 } |
| 231 if err := json.Unmarshal(bData, &data); err != nil { | 233 if err := json.Unmarshal(bData, &data); err != nil { |
| 232 logging.WithError(err).Errorf(c, "could not parse pubsub message
data") | 234 logging.WithError(err).Errorf(c, "could not parse pubsub message
data") |
| 233 return err | 235 return err |
| 234 } | 236 } |
| 235 | 237 |
| 236 return handlePubSubBuild(c, &data) | 238 return handlePubSubBuild(c, &data) |
| 237 } | 239 } |
| OLD | NEW |