Skip to content

Commit 026a74a

Browse files
sed-iAdam Dyess
andauthored
Keep all packed charms, if there are more than one (#115)
* Update plugin.py * linting... * Address 'referenced before assignment' --------- Co-authored-by: Adam Dyess <adam.dyess@canonical.com>
1 parent 78e92ed commit 026a74a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pytest_operator/plugin.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ async def build_charm(
931931
verbosity: Optional[
932932
Literal["quiet", "brief", "verbose", "debug", "trace"]
933933
] = None,
934-
) -> Path:
934+
) -> Optional[Path]:
935935
"""Builds a single charm.
936936
937937
This can handle charms using the older charms.reactive framework as
@@ -1006,9 +1006,15 @@ async def build_charm(
10061006
f"Failed to build charm {charm_path}:\n{stderr}\n{stdout}"
10071007
)
10081008

1009-
charm_file_src = next(charm_abs.glob(f"{charm_name}*.charm"))
1010-
charm_file_dst = charms_dst_dir / charm_file_src.name
1011-
charm_file_src.rename(charm_file_dst)
1009+
# If charmcraft.yaml has multiple bases
1010+
# then multiple charms would be generated.
1011+
charm_file_dst = None
1012+
for charm_file_src in charm_abs.glob(f"{charm_name}*.charm"):
1013+
charm_file_dst = charms_dst_dir / charm_file_src.name
1014+
charm_file_src.rename(charm_file_dst)
1015+
1016+
# Even though we may have multiple *.charm file,
1017+
# for backwards compatibility we can - only return one.
10121018
return charm_file_dst
10131019

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

0 commit comments

Comments
 (0)