Chromium Code Reviews| Index: scripts/slave/recipe_modules/luci_config/api.py |
| diff --git a/scripts/slave/recipe_modules/luci_config/api.py b/scripts/slave/recipe_modules/luci_config/api.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..69f18ca07997f25c40d67e08ef959f4656269dad |
| --- /dev/null |
| +++ b/scripts/slave/recipe_modules/luci_config/api.py |
| @@ -0,0 +1,36 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from recipe_engine import recipe_api |
| + |
| +class LuciConfigApi(recipe_api.RecipeApi): |
| + def get_projects(self): |
| + """Fetch the mapping of project id to url from luci-config. |
| + |
| + Returns: |
| + A dictionary mapping project id to its luci-config project spec (among |
| + which there is a repo_url key). |
| + """ |
| + cmd = ['curl', 'https://luci-config.appspot.com/_ah/api/config/v1/projects'] |
| + fetch_result = self.m.step('Get project urls', |
|
martiniss
2016/04/07 18:27:59
Please change this to use the fetch module. See ht
Paweł Hajdan Jr.
2016/04/07 20:32:15
Would you be OK with a TODO? This is what recipe_r
martiniss
2016/04/07 21:27:12
A TODO is fine for now.
Paweł Hajdan Jr.
2016/04/08 08:47:00
Good point. Added a TODO.
|
| + cmd, |
| + stdout=self.m.json.output(), |
| + step_test_data=lambda: self.m.json.test_api.output_stream({ |
| + 'projects': [ |
| + { |
| + 'repo_type': 'GITILES', |
| + 'id': 'recipe_engine', |
| + 'repo_url': 'https://repo.repo/recipes-py', |
| + }, |
| + { |
| + 'repo_type': 'GITILES', |
| + 'id': 'build', |
| + 'repo_url': 'https://repo.repo/chromium/build', |
| + } |
| + ], |
| + })) |
| + mapping = {} |
| + for project in fetch_result.stdout['projects']: |
| + mapping[project['id']] = project |
| + return mapping |