Skip to content

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

Merged
cachedout merged 3 commits intosaltstack:developfrom
mwerickso:slack_returner
Apr 5, 2018
Merged

Add support to only return failed states to slack.#46840
cachedout merged 3 commits intosaltstack:developfrom
mwerickso:slack_returner

Conversation

@mwerickso
Copy link
Copy Markdown
Contributor

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 April 4, 2018 15:47
Comment thread salt/returners/slack_returner.py Outdated
as_user,
api_key)
return slack
return slack No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a newline below this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread salt/returners/slack_returner.py Outdated
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@rallytime
Copy link
Copy Markdown
Contributor

rallytime commented Apr 4, 2018

@mwerickso There is a lint error on this change here: https://jenkins.saltstack.com/job/PR/job/salt-pr-lint-n/20708/violations/file/salt/returners/slack_returner.py/

Can you fix that up?

@cachedout cachedout merged commit 4b6251a into saltstack:develop Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants