@@ -548,10 +548,16 @@ async def resolve(self, url, architecture, app_name=None, channel=None, series=N
548548 if channel is not None :
549549 ch = Channel .parse (channel ).normalize ()
550550
551+ base = client .Base ()
552+ if series :
553+ base .channel = ch .normalize ().compute_base_channel (series = series )
554+ base .name = 'ubuntu'
551555 origin = client .CharmOrigin (source = "charm-hub" ,
552556 architecture = architecture ,
553557 risk = ch .risk ,
554- track = ch .track )
558+ track = ch .track ,
559+ base = base ,
560+ )
555561
556562 charm_url_str , origin , supported_series = await self .charm_resolver (url , origin )
557563 charm_url = URL .parse (charm_url_str )
@@ -1856,12 +1862,28 @@ async def _add_charm(self, charm_url, origin):
18561862 return await client_facade .AddCharm (channel = str (origin .risk ), url = charm_url , force = False )
18571863
18581864 async def _resolve_charm (self , url , origin ):
1865+ """Calls Charms.ResolveCharms to resolve all the fields of the
1866+ charm_origin and also the url and the supported_series
1867+
1868+ :param str url: The url of the charm
1869+ :param client.CharmOrigin origin: The manually constructed origin
1870+ based on what we know about the charm and the deployment so far
1871+
1872+ Returns the confirmed origin returned by the Juju API to be used in
1873+ calls like ApplicationFacade.Deploy
1874+
1875+ :returns str, client.CharmOrigin, [str]
1876+ """
18591877 charms_cls = client .CharmsFacade
18601878 if charms_cls .best_facade_version (self .connection ()) < 3 :
18611879 raise JujuError ("resolve charm" )
18621880
18631881 charms_facade = charms_cls .from_connection (self .connection ())
18641882
1883+ # TODO (cderici): following part can be refactored out, since the
1884+ # origin should be set (including the base) before calling this,
1885+ # though all tests need to run (in earlier versions too) before
1886+ # committing to make sure there's no regression
18651887 if Schema .CHARM_STORE .matches (url .schema ):
18661888 source = "charm-store"
18671889 else :
0 commit comments