You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by mc...@apache.org on 2014/06/02 16:53:38 UTC
git commit: Modify the way that config binding helpers get registered.
Repository: incubator-aurora
Updated Branches:
refs/heads/master e7b93b222 -> b772bff32
Modify the way that config binding helpers get registered.
Config binding helpers (components that add macros to the pystachio
config language) self-registered in a way that made it difficult to
provide parameters to initialize them.
This change switches to an explicit construction/registration, instead
of auto-construction when the class is registered. (Interestingly, this
is the way that the documentation on the binding helpers code says that
it works!)
With this change, instead of writing:
FooHelper.register()
You write:
BindingHelper.register(FooHelper())
Which makes it possible to do:
BindingHelper.register(FooHelper(url=bar))
Testing Done:
All client unit tests run and passed.
Bugs closed: aurora-496
Reviewed at https://reviews.apache.org/r/22082/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/b772bff3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/b772bff3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/b772bff3
Branch: refs/heads/master
Commit: b772bff321427eed1c687f49273abd679b161f27
Parents: e7b93b2
Author: Mark Chu-Carroll <mc...@twopensource.com>
Authored: Mon Jun 2 10:46:14 2014 -0400
Committer: Mark Chu-Carroll <mc...@twitter.com>
Committed: Mon Jun 2 10:46:14 2014 -0400
----------------------------------------------------------------------
src/main/python/apache/aurora/client/binding_helper.py | 7 ++++---
src/test/python/apache/aurora/client/test_binding_helper.py | 8 ++++----
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/b772bff3/src/main/python/apache/aurora/client/binding_helper.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/binding_helper.py b/src/main/python/apache/aurora/client/binding_helper.py
index 47448e0..d17d57e 100644
--- a/src/main/python/apache/aurora/client/binding_helper.py
+++ b/src/main/python/apache/aurora/client/binding_helper.py
@@ -63,9 +63,10 @@ class BindingHelper(Interface):
(because a human reader wants to know the version of the package, not the meaningless
HDFS URL.
"""
- @classmethod
- def register(cls):
- _BINDING_HELPERS.append(cls())
+ @staticmethod
+ def register(helper):
+ _BINDING_HELPERS.append(helper)
+
def apply(self, config, env=None, binding_dict=None):
for match in self.matcher.match(config.raw()):
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/b772bff3/src/test/python/apache/aurora/client/test_binding_helper.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/test_binding_helper.py b/src/test/python/apache/aurora/client/test_binding_helper.py
index e909a05..cc9397b 100644
--- a/src/test/python/apache/aurora/client/test_binding_helper.py
+++ b/src/test/python/apache/aurora/client/test_binding_helper.py
@@ -102,10 +102,10 @@ def test_registry():
binding_helper.unregister_all()
assert len(binding_helper._BINDING_HELPERS) == 0
- UncachedHelper.register()
+ BindingHelper.register(UncachedHelper())
assert len(binding_helper._BINDING_HELPERS) == 1
- CachedHelper.register()
+ BindingHelper.register(CachedHelper())
assert len(binding_helper._BINDING_HELPERS) == 2
binding_helper.unregister_all()
@@ -114,8 +114,8 @@ def test_registry():
def test_helper_types():
binding_helper.unregister_all()
- UncachedHelper.register()
- CachedHelper.register()
+ BindingHelper.register(UncachedHelper())
+ BindingHelper.register(CachedHelper())
uncached_helper = binding_helper._BINDING_HELPERS[0]
cached_helper = binding_helper._BINDING_HELPERS[1]