From fe2e4eba9614f69330db6f95631f5ca705fbd817 Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Tue, 8 Mar 2022 15:26:09 -0700 Subject: [PATCH] Fix for different types of AddCharm return values Older versions (using the ClientFacade) return a dictionary and newer versions return an object (CharmOriginResult). --- juju/model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/juju/model.py b/juju/model.py index f3d81a082..a52fc2f75 100644 --- a/juju/model.py +++ b/juju/model.py @@ -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,