diff --git a/hab/parsers/flat_config.py b/hab/parsers/flat_config.py index 50a239b..c40015b 100644 --- a/hab/parsers/flat_config.py +++ b/hab/parsers/flat_config.py @@ -157,9 +157,6 @@ def extract_global_keys(operation, merged_env, global_env): def aliases(self): """List of the names and commands that need created to launch desired applications.""" - if "aliases" in self.frozen_data: - return self.frozen_data.get("aliases", {}).get(utils.Platform.name(), {}) - return self.frozen_data.get("aliases", {}).get(utils.Platform.name(), {}) @property @@ -236,7 +233,11 @@ def versions(self): # If this version defines any alias_mods, store them for later if version.alias_mods: - for name, mod in version.alias_mods.items(): + # Format the alias environment at this point so any path + # based variables like {relative_root} are resolved against + # the version's directory not the alias being modified + mods = version.format_environment_value(version.alias_mods) + for name, mod in mods.items(): self._alias_mods.setdefault(name, []).append(mod) return self.frozen_data["versions"] diff --git a/hab/parsers/hab_base.py b/hab/parsers/hab_base.py index d6af296..f84a7c7 100644 --- a/hab/parsers/hab_base.py +++ b/hab/parsers/hab_base.py @@ -391,6 +391,9 @@ def format_environment_value(self, value, ext=None, platform=None): k: self.format_environment_value(v, ext=ext, platform=platform) for k, v in value.items() } + elif isinstance(value, bool): + # Just return boolean values, no need to format + return value # Expand and format any variables like "relative_root" using the current # platform for paths. diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 5526775..e59f67b 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -753,8 +753,10 @@ def test_alias_mods_as_dict(resolver): env = alias["environment"] # Check alias_mod is prepended to alias defined env var - assert env['ALIASED_LOCAL'][0].endswith("modified") - assert env['ALIASED_LOCAL'][1].endswith('test') + # Also check that the alias_mods {relative_root} path is resolved to the directory + assert env['ALIASED_LOCAL'][0].endswith("distros/aliased_mod/1.0/modified") + # Check that the alias {relative_root} path is resolved to it's directory + assert env['ALIASED_LOCAL'][1].endswith('distros/aliased/2.0/test') # Env var can be set by alias_mod without any other hab management assert env['ALIASED_MOD_LOCAL_A'] == ['Local Mod A']