Skip to content

Commit e6373ab

Browse files
committed
Handle local charms with better care for CharmOrigin
1 parent ed5c7d7 commit e6373ab

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

juju/bundle.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async def _handle_local_charms(self, bundle, bundle_dir):
129129
default_series or
130130
await get_charm_series(charm_dir, self.model)
131131
)
132-
if not series:
132+
if not self.model.connection().is_using_old_client and not series:
133133
raise JujuError(
134134
"Couldn't determine series for charm at {}. "
135135
"Add a 'series' key to the bundle.".format(charm_dir))
@@ -148,15 +148,24 @@ async def _handle_local_charms(self, bundle, bundle_dir):
148148
])
149149

150150
# Update the 'charm:' entry for each app with the new 'local:' url.
151-
for app_name, charm_url, (charm_dir, _) in zip(apps, charm_urls, args):
151+
for app_name, charm_url, (charm_dir, series) in zip(apps,
152+
charm_urls, args):
153+
metadata = utils.get_local_charm_metadata(charm_dir)
152154
resources = await self.model.add_local_resources(
153155
app_name,
154156
charm_url,
155-
utils.get_local_charm_metadata(charm_dir),
157+
metadata,
156158
resources=bundle.get('applications', {app_name: {}})[app_name].get("resources", {}),
157159
)
158160
apps_dict[app_name]['charm'] = charm_url
159161
apps_dict[app_name]["resources"] = resources
162+
origin = client.CharmOrigin(source="local", risk="stable")
163+
if not self.model.connection().is_using_old_client:
164+
origin.base = utils.get_local_charm_base(series, '',
165+
metadata,
166+
charm_dir,
167+
client.Base)
168+
self.origins[charm_url] = {str(None): origin}
160169

161170
return bundle
162171

@@ -629,7 +638,7 @@ async def run(self, context):
629638
self.application, charm, origin, overrides=self.resources)
630639
else:
631640
resources = context.bundle.get("applications", {}).get(self.application, {}).get("resources", {})
632-
641+
import pdb;pdb.set_trace()
633642
await context.model._deploy(
634643
charm_url=charm,
635644
application=self.application,
@@ -723,8 +732,9 @@ async def run(self, context):
723732
ch = None
724733
identifier = None
725734
if Schema.LOCAL.matches(url.schema):
726-
origin = client.CharmOrigin(source="local", risk="stable")
727-
context.origins[self.charm] = {str(None): origin}
735+
# origin = client.CharmOrigin(source="local", risk="stable")
736+
import pdb;pdb.set_trace()
737+
# context.origins[self.charm] = {str(None): origin}
728738
return self.charm
729739

730740
if Schema.CHARM_STORE.matches(url.schema):

0 commit comments

Comments
 (0)