Skip to content

Commit

Permalink
Try to make configs available for actors to import.
Browse files Browse the repository at this point in the history
  • Loading branch information
abadger committed Sep 13, 2024
1 parent 22dbc5b commit b1f67db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions leapp/repository/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def load(self, resolve=True, stage=None, skip_actors_discovery=False):
self.log.debug("Installing repository provided common libraries loader hook")
sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.libraries.common', paths=self.libraries))
sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.workflows.api', paths=self.apis))
sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.configs', paths=self.configs))

if not skip_actors_discovery:
if not stage or stage is _LoadStage.ACTORS:
Expand Down Expand Up @@ -189,6 +190,7 @@ def mapped_actor_data(data):
})
return data

# TODO: Do we need to add configs here as well?
return {
'repo_dir': self._repo_dir,
'actors': [mapped_actor_data(a.serialize()) for a in self.actors],
Expand Down Expand Up @@ -268,6 +270,13 @@ def libraries(self):
"""
return tuple(self._definitions.get(DefinitionKind.LIBRARIES, ()))

@property
def configs(self):
"""
:return: Tuple of configs in the repository
"""
return tuple(self._definitions.get(DefinitionKind.CONFIGS, ()))

@property
def files(self):
"""
Expand Down
16 changes: 16 additions & 0 deletions leapp/repository/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def scan(repository, path):
('workflows', scan_workflows),
('files', scan_files),
('libraries', scan_libraries),
('configs', scan_configs),
('tests', scan_tests),
('tools', scan_tools),
('apis', scan_apis))
Expand Down Expand Up @@ -224,6 +225,21 @@ def scan_libraries(repo, path, repo_path):
repo.add(DefinitionKind.LIBRARIES, os.path.relpath(path, repo_path))


def scan_configs(repo, path, repo_path):
"""
Scans configs and adds them to the repository.
:param repo: Instance of the repository
:type repo: :py:class:`leapp.repository.Repository`
:param path: path to the configs
:type path: str
:param repo_path: path to the repository
:type repo_path: str
"""
if os.listdir(path):
repo.add(DefinitionKind.CONFIGS, os.path.relpath(path, repo_path))


def scan_tools(repo, path, repo_path):
"""
Scans tools and adds them to the repository.
Expand Down

0 comments on commit b1f67db

Please sign in to comment.