@@ -647,26 +647,30 @@ async def refresh(
647647
648648 app_facade = self ._facade ()
649649
650- charm_url = self .data ['charm-url' ]
651- parsed_url = URL .parse (charm_url )
650+ url = switch or self .data ['charm-url' ]
651+ parsed_url = URL .parse (url )
652652 charm_name = parsed_url .name
653653
654654 # First we need to make sure we have the resources for the charm that's
655655 # coming
656656
657+ if parsed_url .schema is None :
658+ raise JujuError (f'A ch: or cs: schema is required for application refresh, given : { str (parsed_url )} ' )
659+
657660 # Get the list of resources needed to deploy this charm
658661 if Schema .CHARM_HUB .matches (parsed_url .schema ):
659662 # Charmhub charms
660663 charmhub = self .model .charmhub
661664 charm_resources = await charmhub .list_resources (charm_name )
662665
663- charm_url_origin_result = await app_facade .GetCharmURLOrigin (application = charm_name )
666+ charm_url_origin_result = await app_facade .GetCharmURLOrigin (application = self . name )
664667
665668 if charm_url_origin_result .error is not None :
666669 err = charm_url_origin_result .error
667670 raise JujuError (f'{ err .code } : { err .message } ' )
668- charm_url = charm_url_origin_result .url
671+ charm_url = switch or charm_url_origin_result .url
669672 origin = charm_url_origin_result .charm_origin
673+ origin .source = 'charm-hub'
670674
671675 if channel :
672676 ch = Channel .parse (channel ).normalize ()
@@ -676,7 +680,7 @@ async def refresh(
676680 charms_facade = client .CharmsFacade .from_connection (self .connection )
677681 resolved_charm_with_channel_results = await charms_facade .ResolveCharms (resolve = [client .ResolveCharmWithChannel (
678682 charm_origin = origin ,
679- switch_charm = False ,
683+ switch_charm = True if switch else False , # rpc expects boolean type
680684 reference = charm_url ,
681685 )])
682686 resolved_charm = resolved_charm_with_channel_results .results [0 ]
0 commit comments