| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. | 1 // Copyright 2016 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 return datastore.Put(c, b) | 226 return datastore.Put(c, b) |
| 227 } | 227 } |
| 228 | 228 |
| 229 // saveBuildSummary summerizes a build into a model.BuildSummary and then saves
it. | 229 // saveBuildSummary summerizes a build into a model.BuildSummary and then saves
it. |
| 230 func saveBuildSummary(c context.Context, b *buildbotBuild) error { | 230 func saveBuildSummary(c context.Context, b *buildbotBuild) error { |
| 231 resp := renderBuild(c, b) | 231 resp := renderBuild(c, b) |
| 232 bs := model.BuildSummary{ | 232 bs := model.BuildSummary{ |
| 233 BuildKey: datastore.KeyForObj(c, b), | 233 BuildKey: datastore.KeyForObj(c, b), |
| 234 BuilderID: fmt.Sprintf("buildbot/%s/%s", b.Master, b.Buildername
), | 234 BuilderID: fmt.Sprintf("buildbot/%s/%s", b.Master, b.Buildername
), |
| 235 } | 235 } |
| 236 » resp.SummarizeTo(&bs) | 236 » if err := resp.SummarizeTo(c, &bs); err != nil { |
| 237 » » return err |
| 238 » } |
| 237 return datastore.Put(c, &bs) | 239 return datastore.Put(c, &bs) |
| 238 } | 240 } |
| 239 | 241 |
| 240 func doMaster(c context.Context, master *buildbotMaster, internal bool) int { | 242 func doMaster(c context.Context, master *buildbotMaster, internal bool) int { |
| 241 // Store the master json into the datastore. | 243 // Store the master json into the datastore. |
| 242 err := putDSMasterJSON(c, master, internal) | 244 err := putDSMasterJSON(c, master, internal) |
| 243 fullname := fmt.Sprintf("master.%s", master.Name) | 245 fullname := fmt.Sprintf("master.%s", master.Name) |
| 244 if err != nil { | 246 if err != nil { |
| 245 logging.WithError(err).Errorf( | 247 logging.WithError(err).Errorf( |
| 246 c, "Could not save master in datastore %s", err) | 248 c, "Could not save master in datastore %s", err) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 427 |
| 426 } | 428 } |
| 427 if master != nil { | 429 if master != nil { |
| 428 code := doMaster(c, master, internal) | 430 code := doMaster(c, master, internal) |
| 429 if code != 0 { | 431 if code != 0 { |
| 430 return code | 432 return code |
| 431 } | 433 } |
| 432 } | 434 } |
| 433 return http.StatusOK | 435 return http.StatusOK |
| 434 } | 436 } |
| OLD | NEW |