Skip to content

Commit 009e9c3

Browse files
committed
Revise the application.upgrade_charm (refresh)
fixes #728
1 parent fbdab09 commit 009e9c3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

juju/application.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pathlib
1919

2020
from . import model, tag, utils, jasyncio
21+
from .url import URL
2122
from .status import derive_status
2223
from .annotationhelper import _get_annotations, _set_annotations
2324
from .client import client
@@ -619,7 +620,6 @@ async def refresh(
619620
if switch is not None and revision is not None:
620621
raise ValueError("switch and revision are mutually exclusive")
621622

622-
client_facade = client.ClientFacade.from_connection(self.connection)
623623
resources_facade = client.ResourcesFacade.from_connection(
624624
self.connection)
625625
app_facade = self._facade()
@@ -650,12 +650,12 @@ async def refresh(
650650
force=force,
651651
channel=channel
652652
)
653+
charm_url = self.data['charm-url']
654+
charm_name = URL.parse(charm_url).name
653655

654656
# Update resources
655-
if not charmstore_entity:
656-
charmstore_entity = await charmstore.entity(charm_url,
657-
channel=channel)
658-
store_resources = charmstore_entity['Meta']['resources']
657+
charmhub = self.model.charmhub
658+
charmhub_resources = await charmhub.list_resources(charm_name)
659659

660660
request_data = [client.Entity(self.tag)]
661661
response = await resources_facade.ListResources(entities=request_data)
@@ -665,7 +665,7 @@ async def refresh(
665665
}
666666

667667
resources_to_update = [
668-
resource for resource in store_resources
668+
resource for resource in charmhub_resources
669669
if resource['Name'] not in existing_resources or
670670
existing_resources[resource['Name']].origin != 'upload'
671671
]

0 commit comments

Comments
 (0)