| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if err != nil { | 291 if err != nil { |
| 292 return nil, err | 292 return nil, err |
| 293 } | 293 } |
| 294 for _, cs := range p.Consoles { | 294 for _, cs := range p.Consoles { |
| 295 if cs.Name == consoleName { | 295 if cs.Name == consoleName { |
| 296 return cs, nil | 296 return cs, nil |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 return nil, fmt.Errorf("Console %s not found in project %s", consoleName
, projName) | 299 return nil, fmt.Errorf("Console %s not found in project %s", consoleName
, projName) |
| 300 } | 300 } |
| 301 |
| 302 // ProjectConsole is a simple tuple type for GetConsolesForBuilder. |
| 303 type ProjectConsole struct { |
| 304 ProjectID string |
| 305 Console *config.Console |
| 306 } |
| 307 |
| 308 // GetConsolesForBuilder retrieves all the console definitions that this builder |
| 309 // belongs to. |
| 310 func GetConsolesForBuilder(c context.Context, builderName string) ([]*ProjectCon
sole, error) { |
| 311 projs, err := GetAllProjects(c) |
| 312 if err != nil { |
| 313 return nil, err |
| 314 } |
| 315 ret := []*ProjectConsole{} |
| 316 for _, p := range projs { |
| 317 for _, con := range p.Consoles { |
| 318 for _, b := range con.Builders { |
| 319 if b.Name == builderName { |
| 320 ret = append(ret, &ProjectConsole{p.ID,
con}) |
| 321 } |
| 322 } |
| 323 } |
| 324 } |
| 325 return ret, nil |
| 326 } |
| OLD | NEW |