Skip to content

Commit 0deb618

Browse files
committed
Add validation for bundles to require either --revision or --channel
Otherwise fail early without making any additional API calls.
1 parent b518f0c commit 0deb618

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

juju/model.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ async def resolve(self, url, architecture, app_name=None, channel=None, series=N
500500
underlying origin.
501501
"""
502502
if revision and not channel:
503-
raise JujuError('ERROR specifying a revision requires a channel for future upgrades. Please use --channel')
503+
raise JujuError('specifying a revision requires a channel for future upgrades. Please use --channel')
504504

505505
ch = Channel('latest', 'stable')
506506
if channel is not None:
@@ -519,6 +519,11 @@ async def resolve(self, url, architecture, app_name=None, channel=None, series=N
519519
)
520520

521521
charm_url_str, origin, supported_series = await self.charm_resolver(url, origin)
522+
523+
is_bundle = origin.type_ == "bundle"
524+
if is_bundle and revision and channel:
525+
raise JujuError('revision and channel are mutually exclusive when deploying a bundle. Please choose one.')
526+
522527
charm_url = URL.parse(charm_url_str)
523528

524529
if app_name is None:
@@ -535,7 +540,7 @@ async def resolve(self, url, architecture, app_name=None, channel=None, series=N
535540
identifier=str(charm_url),
536541
app_name=app_name,
537542
origin=origin,
538-
is_bundle=origin.type_ == "bundle",
543+
is_bundle=is_bundle,
539544
)
540545

541546

0 commit comments

Comments
 (0)