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

Add support to only return failed states to slack. #46840

Merged
merged 3 commits into from Apr 5, 2018

Conversation

@mwerickso
Copy link
Contributor

@mwerickso mwerickso commented Apr 3, 2018

What does this PR do?

Add support to only return failed states to slack via slack_retuner.

What issues does this PR fix or reference?

N/A

Previous Behavior

Previously, using changes: true returned both states that had changes and states that failed.

New Behavior

Now, you can still use changes: true to return changed and failed states, or you can use only_show_failed: true to only return failed states.

Tests written?

No

Commits signed with GPG?

Yes

@cachedout cachedout requested a review from gtmanfred Apr 4, 2018
@@ -231,4 +241,4 @@ def returner(ret):
username,
as_user,
api_key)
return slack
return slack
Copy link
Contributor

@cachedout cachedout Apr 4, 2018

Please add a newline below this.

Copy link
Contributor Author

@mwerickso mwerickso Apr 4, 2018

@cachedout Sorry I didnt notice it got deleted. Added back in.

returns = ret.get('return')
if changes is True:
returns = dict((key, value) for key, value in returns.items() if value['result'] is not True or value['changes'])

if only_show_failed is True:
returns = dict((key, value) for key, value in returns.items() if value['result'] is not True)
Copy link
Contributor

@gtmanfred gtmanfred Apr 4, 2018

This should be switched to dictionary interpretation, since we no longer support py2.6.

{key, value for key, value in returns.items() if value['result'] is not True}

This is significantly faster.

Copy link
Contributor Author

@mwerickso mwerickso Apr 4, 2018

@gtmanfred Good to know, updated lines 218 and 221 with new method.

@rallytime
Copy link
Contributor

@rallytime rallytime commented Apr 4, 2018

@cachedout cachedout merged commit 4b6251a into saltstack:develop Apr 5, 2018
5 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants