Skip to content

Commit

Permalink
Fix dict contain check for should_upgrade_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
cderici committed Aug 31, 2023
1 parent 29eff51 commit 920a651
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions juju/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,13 @@ def should_upgrade_resource(available_resource, existing_resources):
"""
# should upgrade resource?
res_name = available_resource.get('Name', available_resource.get('name'))
# no, if it's upload
if existing_resources[res_name].origin == 'upload':
return False

# no, if we already have it (and upstream doesn't have a newer res available)
# do we have it already?
if res_name in existing_resources:
# no upgrade, if it's upload
if existing_resources[res_name].origin == 'upload':
return False
# no upgrade, if upstream doesn't have a newer revision of the resource available
available_rev = available_resource.get('Revision', available_resource.get('revision', -1))
u_fields = existing_resources[res_name].unknown_fields
existing_rev = u_fields.get('Revision', u_fields.get('revision', -1))
Expand Down

0 comments on commit 920a651

Please sign in to comment.