Skip to content

Commit db6be93

Browse files
committed
Fix 'metadata referenced before assignment' error
For the life of me, I can't figure out how this wasn't caught by the test added in #486.
1 parent a175d76 commit db6be93

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

juju/model.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from . import provisioner, tag, utils
2222
from .annotationhelper import _get_annotations, _set_annotations
2323
from .bundle import BundleHandler, get_charm_series
24+
from .charm import get_local_charm_metadata
2425
from .charmhub import CharmHub
2526
from .charmstore import CharmStore
2627
from .client import client, connector
@@ -1419,7 +1420,6 @@ async def deploy(
14191420
entity_url = str(entity_url) # allow for pathlib.Path objects
14201421
entity_path = Path(entity_url.replace('local:', ''))
14211422
bundle_path = entity_path / 'bundle.yaml'
1422-
metadata_path = entity_path / 'metadata.yaml'
14231423

14241424
is_local = (
14251425
entity_url.startswith('local:') or
@@ -1470,12 +1470,8 @@ async def deploy(
14701470
entity_id,
14711471
entity=entity)
14721472
else:
1473+
metadata = get_local_charm_metadata(entity_path)
14731474
if not application_name:
1474-
if str(entity_path).endswith('.charm'):
1475-
with zipfile.ZipFile(entity_path, 'r') as charm_file:
1476-
metadata = yaml.load(charm_file.read('metadata.yaml'), Loader=yaml.FullLoader)
1477-
else:
1478-
metadata = yaml.load(metadata_path.read_text(), Loader=yaml.FullLoader)
14791475
application_name = metadata['name']
14801476
# We have a local charm dir that needs to be uploaded
14811477
charm_dir = os.path.abspath(

0 commit comments

Comments
 (0)