Skip to content
This repository was archived by the owner on Jan 19, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions atomicapp/nulecule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def load_components(self, nodeps=False, dryrun=False):
node_name = node[NAME_KEY]
source = Utils.getSourceImage(node)
component = NuleculeComponent(
node_name, self.basepath, source,
node.get(PARAMS_KEY), node.get(ARTIFACTS_KEY),
self._get_component_namespace(node_name), self.basepath,
source, node.get(PARAMS_KEY), node.get(ARTIFACTS_KEY),
self.config)
component.load(nodeps, dryrun)
components.append(component)
Expand All @@ -246,6 +246,12 @@ def render(self, provider_key=None, dryrun=False):
for component in self.components:
component.render(provider_key=provider_key, dryrun=dryrun)

def _get_component_namespace(self, component_name):
current_namespace = '' if self.namespace == GLOBAL_CONF else self.namespace
return (
'%s__%s' % (current_namespace, component_name)
if current_namespace else component_name)


class NuleculeComponent(NuleculeBase):

Expand Down Expand Up @@ -334,7 +340,8 @@ def load_external_application(self, dryrun=False, update=False):
'Found existing external application for %s. '
'Loading it.' % self.name)
nulecule = Nulecule.load_from_path(
external_app_path, dryrun=dryrun, update=update)
external_app_path, dryrun=dryrun, update=update,
namespace=self.namespace)
elif not dryrun:
logger.info('Pulling external application for %s.' % self.name)
nulecule = Nulecule.unpack(
Expand Down
6 changes: 6 additions & 0 deletions atomicapp/nulecule/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def load_config(self, config, ask=False, skip_asking=False):
Returns:
None
"""
parent_namespace = self._get_parent_namespace()
for param in self.params:
value = config.get(self.namespace, {}).get(param[NAME_KEY]) or \
config.get(parent_namespace, {}).get(param[NAME_KEY]) or \
config.get(GLOBAL_CONF, {}).get(param[NAME_KEY])
if value is None and (ask or (
not skip_asking and param.get(DEFAULTNAME_KEY) is None)):
Expand Down Expand Up @@ -109,3 +111,7 @@ def fetch(self):

def uninstall(self):
raise NotImplementedError

def _get_parent_namespace(self):
tokens = self.namespace.split('__')
return '__'.join(tokens[:-1]) if len(tokens) > 1 else GLOBAL_CONF