Repository navigation
Fix slack engine to run on python2.6 - #33601
Conversation
Deduplicate alias handling to autodetect function selection. Add error reporting to slack connectivty problems. Cleanup slack's unicode conversion
|
Just pushed a much cleaner version of unicode handling. While it might be a mild hack to convert to json and back, those modules handle the decoding properly and make the code future proof. This commit also cleans up lint errors, evaluates alias commands the same as standard ones, properly prints json to slack allowing for correct syntax highlighting, and adds error reporting for connection issues. All in all, this is a large bug fix over what was shipped in 2016.3 and after review should be evaluated for backport. |
|
This looks pretty good to me. What do you think, @garethgreenaway ? |
|
@mchugh19 We do need a minor lint error fixed though, please. https://jenkins.saltstack.com/job/PR/job/salt-pr-lint-n/2191/violations/file/salt/engines/slack.py/ |
|
@cachedout Looks good, just reviewing now. |
| cmdline = salt.utils.shlex_split(_text[len(trigger):]) | ||
|
|
||
| # Remove inital salt item from list | ||
| if cmdline[0] == 'salt': |
There was a problem hiding this comment.
Not sure about this one. The first bit of the command is the trigger so if !salt is the trigger then is should get removed during the for loop on cmdline. Seems confusing to have ! be the trigger but also include salt.
There was a problem hiding this comment.
Right you are. I had somehow gotten it into my head that the trigger was !salt service.restart...
Would it be appropriate to expand the trigger as a single "!" is pretty generic? There could be other integrations that also operate on a short triggers, so a unique key seems important.
|
@cachedout Added some comments but overall looks great. |
|
@garethgreenaway Thanks as always for the quick feedback! @mchugh19 Let me know when you've had a chance to look all this over. Thank you! |
|
@cachedout fixed lint spacing error. @garethgreenaway Whatever you think for the trigger. I like the Also, I added a hipchat engine to mirror this one. So if we decide on "!" I'll update hipchat to match. |
|
@mchugh19 I personally like !salt too but it's configurable in the engine configuration using the |
|
@garethgreenaway Done and done. |
|
👍 |
|
ping @rallytime can we get this backported? It seems to be fixed in 2016.11 but users in 2016.3 will still be effected as shown in issue: #33618 |
|
Sure. Please see #38531 |
What does this PR do?
Fixes issue where slack user doesn't have an is_bot key
Allows engine to run on rhel6 with python 2.6 with unicode conversion
Corrects for slack's autoparsing of url looking text. Commands like:
!salt test.ping target=hostname.domain.comshould now be handled properly.Tests written?
No
I am not a python unicode wizard, so please don't take my word for it. While this fixes the engine for my python2.6 environment, there might be better ways of handling something maybe with python 3 in mind. So this works for me and likely corrects it for others, but please review.