Skip to content

Commit

Permalink
ecs_ecr - Use compare_policies instead of naive dict sort (ansible-co…
Browse files Browse the repository at this point in the history
…llections#1551)

ecs_ecr - Use compare_policies instead of naive dict sort

Depends-On: ansible-collections#1550
SUMMARY
When comparing policies on the repos ecs_ecr currently uses a very naive sort function.  Since we have something more comprehensive, use it.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/ecs_ecr.py
ADDITIONAL INFORMATION
ecs_ecr is currently the only module using sort_json_policy_dict and it has poor test coverage.

Reviewed-by: Markus Bergholz <[email protected]>
  • Loading branch information
tremble authored Oct 7, 2022
1 parent 5204259 commit 3f5f4ab
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions ecs_ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto_exception
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_policies
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import sort_json_policy_dict


def build_kwargs(registry_id):
Expand Down Expand Up @@ -457,17 +456,11 @@ def run(ecr, params):

elif lifecycle_policy_text is not None:
try:
lifecycle_policy = sort_json_policy_dict(lifecycle_policy)
result['lifecycle_policy'] = lifecycle_policy

original_lifecycle_policy = ecr.get_lifecycle_policy(
registry_id, name)

if original_lifecycle_policy:
original_lifecycle_policy = sort_json_policy_dict(
original_lifecycle_policy)

if original_lifecycle_policy != lifecycle_policy:
if compare_policies(original_lifecycle_policy, lifecycle_policy):
ecr.put_lifecycle_policy(registry_id, name,
lifecycle_policy_text)
result['changed'] = True
Expand Down

0 comments on commit 3f5f4ab

Please sign in to comment.