|
18 | 18 | import pathlib |
19 | 19 |
|
20 | 20 | from . import model, tag, utils, jasyncio |
21 | | -from .url import URL, Schema |
| 21 | +from .url import URL |
22 | 22 | from .status import derive_status |
23 | 23 | from .annotationhelper import _get_annotations, _set_annotations |
24 | 24 | from .client import client |
@@ -675,31 +675,14 @@ async def refresh( |
675 | 675 |
|
676 | 676 | # Make the source-specific changes to the origin/channel/url |
677 | 677 | # (and also get the resources necessary to deploy the (destination) charm -- for later) |
678 | | - if Schema.CHARM_HUB.matches(parsed_url.schema): |
679 | | - origin.source = Source.CHARM_HUB |
680 | | - if channel: |
681 | | - ch = Channel.parse(channel).normalize() |
682 | | - origin.risk = ch.risk |
683 | | - origin.track = ch.track |
684 | | - |
685 | | - charmhub = self.model.charmhub |
686 | | - charm_resources = await charmhub.list_resources(charm_name) |
687 | | - else: |
688 | | - charmstore = self.model.charmstore |
689 | | - charmstore_entity = None |
690 | | - if switch is None: |
691 | | - charm_url = charm_url.rpartition('-')[0] |
692 | | - if revision is not None: |
693 | | - charm_url = "%s-%d" % (charm_url, revision) |
694 | | - else: |
695 | | - charmstore_entity = await charmstore.entity(charm_url, channel=channel) |
696 | | - charm_url = charmstore_entity['Id'] |
697 | | - origin.source = 'charm-store' |
698 | | - if channel: |
699 | | - origin.risk = channel |
700 | | - if charmstore_entity is None: |
701 | | - charmstore_entity = await charmstore.entity(charm_url, channel=channel) |
702 | | - charm_resources = charmstore_entity['Meta']['resources'] |
| 678 | + origin.source = Source.CHARM_HUB.value |
| 679 | + if channel: |
| 680 | + ch = Channel.parse(channel).normalize() |
| 681 | + origin.risk = ch.risk |
| 682 | + origin.track = ch.track |
| 683 | + |
| 684 | + charmhub = self.model.charmhub |
| 685 | + charm_resources = await charmhub.list_resources(charm_name) |
703 | 686 |
|
704 | 687 | # Resolve the given charm URLs with an optionally specified preferred channel. |
705 | 688 | # Channel provided via CharmOrigin. |
|
0 commit comments