Skip to content

Commit

Permalink
Keep all packed charms, if there are more than one (#115)
Browse files Browse the repository at this point in the history
* Update plugin.py

* linting...

* Address 'referenced before assignment'

---------

Co-authored-by: Adam Dyess <[email protected]>
  • Loading branch information
sed-i and addyess authored Oct 30, 2023
1 parent 78e92ed commit 026a74a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pytest_operator/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ async def build_charm(
verbosity: Optional[
Literal["quiet", "brief", "verbose", "debug", "trace"]
] = None,
) -> Path:
) -> Optional[Path]:
"""Builds a single charm.
This can handle charms using the older charms.reactive framework as
Expand Down Expand Up @@ -1006,9 +1006,15 @@ async def build_charm(
f"Failed to build charm {charm_path}:\n{stderr}\n{stdout}"
)

charm_file_src = next(charm_abs.glob(f"{charm_name}*.charm"))
charm_file_dst = charms_dst_dir / charm_file_src.name
charm_file_src.rename(charm_file_dst)
# If charmcraft.yaml has multiple bases
# then multiple charms would be generated.
charm_file_dst = None
for charm_file_src in charm_abs.glob(f"{charm_name}*.charm"):
charm_file_dst = charms_dst_dir / charm_file_src.name
charm_file_src.rename(charm_file_dst)

# Even though we may have multiple *.charm file,
# for backwards compatibility we can - only return one.
return charm_file_dst

async def build_charms(self, *charm_paths) -> Mapping[str, Path]:
Expand Down

0 comments on commit 026a74a

Please sign in to comment.