Skip to content

Commit

Permalink
Fixed issue with checking the target of an alias
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
  • Loading branch information
olehermanse committed Dec 8, 2023
1 parent 46690fd commit 72ee2f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion cfbs/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 72ee2f5

Please sign in to comment.