From 72ee2f52f5ff8e2d4af9bc9cdd3b7039fbca3929 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Fri, 8 Dec 2023 17:38:45 +0100 Subject: [PATCH] Fixed issue with checking the target of an alias Signed-off-by: Ole Herman Schumacher Elgesem --- cfbs/cfbs_config.py | 12 ++++++++++++ cfbs/validate.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cfbs/cfbs_config.py b/cfbs/cfbs_config.py index 04bf0ac0..87a7785b 100644 --- a/cfbs/cfbs_config.py +++ b/cfbs/cfbs_config.py @@ -500,3 +500,15 @@ def _get_all_module_names(self, search_in=("build", "provides", "index")): def can_reach_dependency(self, name, search_in=("build", "provides", "index")): return name in self._get_all_module_names() + + def find_module(self, name, search_in=("build", "provides", "index")): + if "build" in search_in and "build" in self: + for module in (x for x in self["build"]): + if module["name"] == name: + return module + if "provides" in search_in and "provides" in self and name in self["provides"]: + return self["provides"][name] + if "index" in search_in and name in self.index: + return self.index[name] + + return None diff --git a/cfbs/validate.py b/cfbs/validate.py index faccc4a0..ca047602 100644 --- a/cfbs/validate.py +++ b/cfbs/validate.py @@ -151,7 +151,7 @@ def validate_alias(name, module, context): raise CFBSValidationError( name, '"alias" must reference another module in the index' ) - if "alias" in modules[module["alias"]]: + if "alias" in config.find_module(module["alias"], search_in): raise CFBSValidationError(name, '"alias" cannot reference another alias') def validate_name(name, module):