Skip to content

Commit

Permalink
Split Copier into Walker and Copier steps (#294)
Browse files Browse the repository at this point in the history
* Split Copier into Walker and Copier steps

* Add test for Copier overwriting files

* Walker now only returns path that need changes to be applied.

* Cache DestinationFile properties and provide container class

Co-authored-by: Bradley A. Thornton <bthornto@redhat.com>

---------

Co-authored-by: Bradley A. Thornton <bthornto@redhat.com>
  • Loading branch information
Qalthos and cidrblock authored Sep 27, 2024
1 parent cb382ad commit 268f6b4
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 110 deletions.
13 changes: 9 additions & 4 deletions src/ansible_creator/subcommands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ansible_creator.exceptions import CreatorError
from ansible_creator.templar import Templar
from ansible_creator.types import TemplateData
from ansible_creator.utils import Copier
from ansible_creator.utils import Copier, Walker


if TYPE_CHECKING:
Expand Down Expand Up @@ -125,14 +125,19 @@ def _scaffold(self) -> None:
dev_file_name=self.unique_name_in_devfile(),
)

copier = Copier(
resources=[f"{self._project}_project", *self.common_resources],
walker = Walker(
resources=(f"{self._project}_project", *self.common_resources),
resource_id=f"{self._project}_project",
dest=self._init_path,
output=self.output,
templar=self._templar,
template_data=template_data,
)
copier.copy_containers()
paths = walker.collect_paths()

copier = Copier(
output=self.output,
)
copier.copy_containers(paths)

self.output.note(f"{self._project} project created at {self._init_path}")
Loading

0 comments on commit 268f6b4

Please sign in to comment.