Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1124)

Unified Diff: scripts/slave/recipe_modules/buildbucket/api.py

Issue 2324733005: BuildBucket recipe module can expose properties. (Closed)
Patch Set: Remove parenthesis. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/buildbucket/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/buildbucket/api.py
diff --git a/scripts/slave/recipe_modules/buildbucket/api.py b/scripts/slave/recipe_modules/buildbucket/api.py
index 572a0b7c2407a65729a6048e0b949bf15bf694c9..8ee0faaf52a34966939665bba98ad47c5280d8f4 100644
--- a/scripts/slave/recipe_modules/buildbucket/api.py
+++ b/scripts/slave/recipe_modules/buildbucket/api.py
@@ -18,6 +18,10 @@ from recipe_engine import recipe_api
class BuildbucketApi(recipe_api.RecipeApi):
"""A module for interacting with buildbucket."""
+ def __init__(self, *args, **kwargs):
+ super(BuildbucketApi, self).__init__(*args, **kwargs)
+ self._properties = None
+
def get_config_defaults(self):
if self.m.platform.is_win:
return {'PLATFORM': 'win'}
@@ -37,9 +41,7 @@ class BuildbucketApi(recipe_api.RecipeApi):
self.set_config('production_buildbucket')
def _tags_for_build(self, bucket, parameters, override_tags=None):
- buildbucket_info = self.m.properties.get('buildbucket', {})
- if isinstance(buildbucket_info, basestring): # pragma: no cover
- buildbucket_info = json.loads(buildbucket_info)
+ buildbucket_info = self.properties or {}
original_tags_list = buildbucket_info.get('build', {}).get('tags', [])
original_tags = dict(t.split(':', 1) for t in original_tags_list)
@@ -56,6 +58,17 @@ class BuildbucketApi(recipe_api.RecipeApi):
new_tags.update(override_tags or {})
return sorted([':'.join((x, y)) for x, y in new_tags.iteritems()])
+ @property
+ def properties(self):
+ """Returns (dict-like or None): The BuildBucket properties, if present."""
+ if self._properties is None:
+ # Not cached, load and deserialize from properties.
+ props = self.m.properties.get('buildbucket')
+ if props is not None:
+ if isinstance(props, basestring):
+ props = json.loads(props)
+ self._properties = props
+ return self._properties
def put(self, builds, service_account=None, **kwargs):
"""Puts a batch of builds.
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/buildbucket/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698