Skip to content

Commit 5e61dd2

Browse files
authored
Merge pull request #459 from SimonRichardson/rename-upgrade-charm-refresh
#459 To remain consistent with juju nomenclature, the following redirects upgrade_charm to refresh. Once juju 3 is released upgrade_charm can be removed (along with other alias methods), to ensure a clean API. This is a purely mechanical change.
2 parents 73604c8 + 8b08293 commit 5e61dd2

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

juju/application.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,18 @@ async def set_trusted(self, trust):
394394
log.debug(
395395
'Setting config for %s: %s', self.name, config)
396396

397-
return await app_facade.SetApplicationsConfig(args=[{
397+
# Unfortunately we have to do this in a lazy fashion, attempting to use
398+
# the method early will cause an error. Attempting to call this
399+
# dynamically causes issues with how the client code is wired up... we
400+
# end up with a missing _toPy attr.
401+
# Using a lambda to only throw it away when it's wrong seems a problem
402+
# as well.
403+
config_method = None
404+
if self._facade_version() < 13:
405+
config_method = app_facade.SetApplicationsConfig
406+
else:
407+
config_method = app_facade.SetConfigs
408+
return await config_method(args=[{
398409
"application": self.name,
399410
"config": config,
400411
}])
@@ -550,20 +561,20 @@ def update_allocation(self, allocation):
550561
"""
551562
raise NotImplementedError()
552563

553-
async def upgrade_charm(
564+
async def refresh(
554565
self, channel=None, force=False, force_series=False, force_units=False,
555566
path=None, resources=None, revision=None, switch=None):
556-
"""Upgrade the charm for this application.
567+
"""Refresh the charm for this application.
557568
558569
:param str channel: Channel to use when getting the charm from the
559570
charm store, e.g. 'development'
560-
:param bool force_series: Upgrade even if series of deployed
571+
:param bool force_series: Refresh even if series of deployed
561572
application is not supported by the new charm
562-
:param bool force_units: Upgrade all units immediately, even if in
573+
:param bool force_units: Refresh all units immediately, even if in
563574
error state
564-
:param str path: Uprade to a charm located at path
575+
:param str path: Refresh to a charm located at path
565576
:param dict resources: Dictionary of resource name/filepath pairs
566-
:param int revision: Explicit upgrade revision
577+
:param int revision: Explicit refresh revision
567578
:param str switch: Crossgrade charm url
568579
569580
"""
@@ -671,6 +682,8 @@ async def upgrade_charm(
671682
lambda: self.data['charm-url'] == charm_url
672683
)
673684

685+
upgrade_charm = refresh
686+
674687
async def get_metrics(self):
675688
"""Get metrics for this application's units.
676689

0 commit comments

Comments
 (0)