OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from recipe_engine import recipe_api |
| 6 |
| 7 class LuciConfigApi(recipe_api.RecipeApi): |
| 8 def get_projects(self): |
| 9 """Fetch the mapping of project id to url from luci-config. |
| 10 |
| 11 Returns: |
| 12 A dictionary mapping project id to its luci-config project spec (among |
| 13 which there is a repo_url key). |
| 14 """ |
| 15 # TODO(phajdan.jr): switch to fetch recipe module. |
| 16 # When we start passing auth token e.g. for internal projects, |
| 17 # it'd be better not to leak it, even on internal-only builders. |
| 18 cmd = ['curl', 'https://luci-config.appspot.com/_ah/api/config/v1/projects'] |
| 19 fetch_result = self.m.step('Get project urls', |
| 20 cmd, |
| 21 stdout=self.m.json.output(), |
| 22 step_test_data=lambda: self.m.json.test_api.output_stream({ |
| 23 'projects': [ |
| 24 { |
| 25 'repo_type': 'GITILES', |
| 26 'id': 'recipe_engine', |
| 27 'repo_url': 'https://repo.repo/recipes-py', |
| 28 }, |
| 29 { |
| 30 'repo_type': 'GITILES', |
| 31 'id': 'build', |
| 32 'repo_url': 'https://repo.repo/chromium/build', |
| 33 } |
| 34 ], |
| 35 })) |
| 36 mapping = {} |
| 37 for project in fetch_result.stdout['projects']: |
| 38 mapping[project['id']] = project |
| 39 return mapping |
OLD | NEW |