Skip to content

Commit

Permalink
Merge branch 'main' into fix/de
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jan 23, 2024
2 parents 55f9577 + cf56667 commit 25c7f89
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cnamespace
cpart
cpath
crepository
csource
fileh
fqcn
levelname
Expand Down
8 changes: 8 additions & 0 deletions src/ansible_dev_environment/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ def parse() -> argparse.Namespace:
dest="venv",
)

level1.add_argument(
"--cpi",
"--collection-pre-install",
help="Pre install collections from source, reads source-requirements.yml file.",
default=False,
action="store_true",
)

level1.add_argument(
"--na",
"--no-ansi",
Expand Down
4 changes: 4 additions & 0 deletions src/ansible_dev_environment/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def parse_args(self: Cli) -> None:
self.args = parse()
if hasattr(self.args, "requirement") and self.args.requirement:
self.args.requirement = Path(self.args.requirement).expanduser().resolve()
if self.args.cpi:
self.args.requirement = (
Path(".config/source-requirements.yml").expanduser().resolve()
)

def init_output(self: Cli) -> None:
"""Initialize the output object."""
Expand Down
1 change: 1 addition & 0 deletions src/ansible_dev_environment/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Collection: # pylint: disable=too-many-instance-attributes
local: bool | None = None
cnamespace: str | None = None
cname: str | None = None
csource: list[str] | None = None
specifier: str | None = None
original: str | None = None

Expand Down
23 changes: 17 additions & 6 deletions src/ansible_dev_environment/subcommands/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def run(self: Installer) -> None:
self._output.critical(err)

self._install_core()

if self._config.args.requirement:
if self._config.args.requirement or self._config.args.cpi:
self._install_galaxy_requirements()
if self._config.args.collection_specifier:
collections = [
Expand Down Expand Up @@ -166,10 +165,19 @@ def _install_galaxy_collections(

def _install_galaxy_requirements(self: Installer) -> None:
"""Install the collections using requirements.yml."""
msg = f"Installing collections from requirements file: {self._config.args.requirement}"
self._output.info(msg)
if self._config.args.requirement and not self._config.args.cpi:
msg = f"Installing collections from requirements file: {self._config.args.requirement}"
self._output.info(msg)
collections = collections_from_requirements(
file=self._config.args.requirement,
)
elif self._config.args.cpi:
msg = "Source installing collections from requirements file source-requirement.yml"
self._output.info(msg)
collections = collections_from_requirements(
file=self._config.args.requirement,
)

collections = collections_from_requirements(file=self._config.args.requirement)
for collection in collections:
cnamespace = collection["name"].split(".")[0]
cname = collection["name"].split(".")[1]
Expand Down Expand Up @@ -201,7 +209,10 @@ def _install_galaxy_requirements(self: Installer) -> None:
self._output.critical(err)

installed = re.findall(r"(\w+\.\w+):.*installed", proc.stdout)
msg = f"Installed collections include: {oxford_join(installed)}"
if not self._config.args.cpi:
msg = f"Installed collections include: {oxford_join(installed)}"
else:
msg = f"Source installed collections include: {oxford_join(installed)}"
self._output.note(msg)

def _copy_git_repo_files(
Expand Down

0 comments on commit 25c7f89

Please sign in to comment.