Skip to content

Commit aa640fc

Browse files
committed
Fixed the bundle run when the channel is None;
Also added a second retrial on the obtention of the bundle's origin (in order to use both the normalized and non normalized channel -> this because some charms cause a failure on obtaining the origin with one type of channel, and others with the other one). Signed-off-by: Pedro Escaleira <pedroescaleira@hotmail.com>
1 parent b5c3185 commit aa640fc

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

juju/bundle.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,26 @@ async def run(self, context):
584584
options["trust"] = "true"
585585

586586
url = URL.parse(str(charm))
587+
588+
# set the channel to the default value if not specified
589+
if not self.channel:
590+
if Schema.CHARM_STORE.matches(url.schema):
591+
self.channel = "stable"
592+
elif Schema.CHARM_HUB.matches(url.schema):
593+
self.channel = "latest/stable"
594+
else: # for local charms
595+
self.channel = ""
596+
587597
channel = None
598+
non_normalized_channel = None
588599
if self.channel is not None and self.channel != "":
589-
channel = Channel.parse(self.channel).normalize()
600+
non_normalized_channel = Channel.parse(self.channel)
601+
channel = non_normalized_channel.normalize()
590602

591-
origin = context.origins.get(str(url), {}).get(str(channel), None)
603+
origin = context.origins.get(str(url), {}).get(
604+
str(channel),
605+
context.origins.get(str(url), {}).get(str(non_normalized_channel), None),
606+
)
592607
if origin is None:
593608
raise JujuError("expected origin to be valid for application {} and charm {} with channel {}".format(self.application, str(url), str(channel)))
594609

0 commit comments

Comments
 (0)