Skip to content

Commit

Permalink
Fix for different types of AddCharm return values
Browse files Browse the repository at this point in the history
Older versions (using the ClientFacade) return a dictionary and newer
versions return an object (CharmOriginResult).
  • Loading branch information
cderici committed Mar 8, 2022
1 parent 8bd0add commit fe2e4eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,12 @@ async def deploy(
# actually support them yet anyway
if not res.is_local:
add_charm_res = await self._add_charm(identifier, res.origin)
charm_origin = add_charm_res.get('charm_origin', res.origin)
if isinstance(add_charm_res, dict):
# This is for backwards compatibility for older
# versions where AddCharm returns a dictionary
charm_origin = add_charm_res.get('charm_origin', res.origin)
else:
charm_origin = add_charm_res.charm_origin

if Schema.CHARM_HUB.matches(url.schema):
resources = await self._add_charmhub_resources(res.app_name,
Expand Down

0 comments on commit fe2e4eb

Please sign in to comment.