From 119e151f9be33bb3d5de89354ddae7483e179aa2 Mon Sep 17 00:00:00 2001 From: Adam Souzis Date: Fri, 15 Sep 2023 14:21:43 -0700 Subject: [PATCH] loader: fix relative parent paths by searching for repository_root --- unfurl/yamlloader.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/unfurl/yamlloader.py b/unfurl/yamlloader.py index efa4be4e..76112586 100644 --- a/unfurl/yamlloader.py +++ b/unfurl/yamlloader.py @@ -444,6 +444,12 @@ def get_remote_tags(self, url, pattern="*") -> List[str]: url = add_user_to_url(url, candidate_parts.username, password) return memoized_remote_tags(url, pattern="*") + def _find_repository_root(self, base): + for repo_view in self.manifest.repositories.values(): + if Path(base).is_relative_to(repo_view.working_dir): + return repo_view.working_dir + return base + def resolve_url( self, importsLoader: toscaparser.imports.ImportsLoader, @@ -470,8 +476,8 @@ def resolve_url( repository_root = None # default to checking if its in the project if importsLoader.repository_root: if toscaparser.imports.is_url(importsLoader.repository_root): - # just make sure we didn't break out of the base - repository_root = base + # at least make sure we didn't break out of the base + repository_root = self._find_repository_root(base) else: repository_root = importsLoader.repository_root if self._has_path_escaped(url, base=repository_root):