Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix. cloudwatchlogs_log_group module wrongly assumes all log group… #52513

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/ansible/modules/cloud/amazon/cloudwatchlogs_log_group.py
Expand Up @@ -259,12 +259,15 @@ def main():
retention=module.params['retention'],
module=module)
elif found_log_group:
if module.params['retention'] != found_log_group['retentionInDays']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simpler fix would be

if module.params['retention'] != found_log_group.get('retentionInDays'):

wouldn't it?

I'm not at all convinced of the need to reformat the call to input_retention_policy - PEP8 does not express a preference either way: https://www.python.org/dev/peps/pep-0008/#id17.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our coding style is "Whatever is enforced by CI"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willthames i've just noticed this comment. Firstly sorry for not replying sooner. I get your point about the reformatting. tbh though its still v.valid. seems a bit silly PR's like this simple one, fixing an actual bug, get stuck on someones personal preference of styling?

if 'retentionInDays' in found_log_group or \
(module.params.get('retention') and 'retentionInDays' not in found_log_group):
changed = True
input_retention_policy(client=logs,
log_group_name=module.params['log_group_name'],
retention=module.params['retention'],
module=module)
input_retention_policy(
client=logs,
log_group_name=module.params['log_group_name'],
retention=module.params['retention'],
module=module
)
found_log_group['retentionInDays'] = module.params['retention']

module.exit_json(changed=changed, **camel_dict_to_snake_dict(found_log_group))
Expand Down