Skip to content

Commit

Permalink
Handle local charms with better care for CharmOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
cderici committed Oct 19, 2022
1 parent ed5c7d7 commit e6373ab
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions juju/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def _handle_local_charms(self, bundle, bundle_dir):
default_series or
await get_charm_series(charm_dir, self.model)
)
if not series:
if not self.model.connection().is_using_old_client and not series:
raise JujuError(
"Couldn't determine series for charm at {}. "
"Add a 'series' key to the bundle.".format(charm_dir))
Expand All @@ -148,15 +148,24 @@ async def _handle_local_charms(self, bundle, bundle_dir):
])

# Update the 'charm:' entry for each app with the new 'local:' url.
for app_name, charm_url, (charm_dir, _) in zip(apps, charm_urls, args):
for app_name, charm_url, (charm_dir, series) in zip(apps,
charm_urls, args):
metadata = utils.get_local_charm_metadata(charm_dir)
resources = await self.model.add_local_resources(
app_name,
charm_url,
utils.get_local_charm_metadata(charm_dir),
metadata,
resources=bundle.get('applications', {app_name: {}})[app_name].get("resources", {}),
)
apps_dict[app_name]['charm'] = charm_url
apps_dict[app_name]["resources"] = resources
origin = client.CharmOrigin(source="local", risk="stable")
if not self.model.connection().is_using_old_client:
origin.base = utils.get_local_charm_base(series, '',
metadata,
charm_dir,
client.Base)
self.origins[charm_url] = {str(None): origin}

return bundle

Expand Down Expand Up @@ -629,7 +638,7 @@ async def run(self, context):
self.application, charm, origin, overrides=self.resources)
else:
resources = context.bundle.get("applications", {}).get(self.application, {}).get("resources", {})

import pdb;pdb.set_trace()
await context.model._deploy(
charm_url=charm,
application=self.application,
Expand Down Expand Up @@ -723,8 +732,9 @@ async def run(self, context):
ch = None
identifier = None
if Schema.LOCAL.matches(url.schema):
origin = client.CharmOrigin(source="local", risk="stable")
context.origins[self.charm] = {str(None): origin}
# origin = client.CharmOrigin(source="local", risk="stable")
import pdb;pdb.set_trace()
# context.origins[self.charm] = {str(None): origin}
return self.charm

if Schema.CHARM_STORE.matches(url.schema):
Expand Down

0 comments on commit e6373ab

Please sign in to comment.