Skip to content

Commit

Permalink
use namespace for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkukral committed Sep 28, 2017
1 parent 0b07655 commit eecd336
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion kqueen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class EtcdOrm:
def __init__(self, **kwargs):
self.client = etcd.Client()
self.namespace = 'default'
self.prefix = kwargs.get('prefix', '/kqueen/obj/')


Expand All @@ -35,7 +36,11 @@ def get_model_name(cls):

@classmethod
def get_db_prefix(cls):
return '{}{}/'.format(db.prefix, cls.get_model_name())
return '{prefix}{namespace}/{model}/'.format(
prefix=db.prefix,
namespace=db.namespace,
model=cls.get_model_name(),
)

@classmethod
def create(cls, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion kqueen/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_get_model_name(self, model_class, req):

def test_get_db_prefix(self):
model_class = Cluster
req = '/kqueen/obj/cluster/'
req = '/kqueen/obj/default/cluster/'

assert model_class.get_db_prefix() == req

Expand Down

0 comments on commit eecd336

Please sign in to comment.