Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Rocketchat plugin #53

Merged
merged 6 commits into from
May 2, 2018
Merged

Conversation

dhollinger
Copy link
Member

No description provided.

@@ -21,6 +21,14 @@ def notify(message)
message,
http_options: @args[:http_options] || {},
icon_emoji: @args[:icon_emoji]).notify
when 'rocketchat'
LOGGER.info("Sending Rocket.Chat webhook message to #{@url}")
Chatops::Rocketchat.new(@channel,
Copy link
Member

Choose a reason for hiding this comment

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

Personally I prefer it when all params in new() are in the next line, limits the indentation to one level

Copy link
Member Author

@dhollinger dhollinger May 1, 2018

Choose a reason for hiding this comment

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

I believe that is against the Ruby Style Guide and I don't think we turned off those cops in Rubocop. I saw failures related to trying to put parameters in-between open/closing parentheses on their own lines. It wants the first and last parameters on the same line as the open/close.

Same goes when calling a class method after the .new(), it wants the final parameter, closing parenthesis, and method call all on the same line.

I'd rather stick to the style guide on this one

Copy link
Member Author

Choose a reason for hiding this comment

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

I found a solution that should satisfy you, @bastelfreak. I'm pretty sure it's close to what you are asking.

@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@dhollinger dhollinger force-pushed the rocketchat_plugin branch 2 times, most recently from dbc524b to c1c363b Compare May 1, 2018 16:49
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@dhollinger dhollinger force-pushed the rocketchat_plugin branch 3 times, most recently from 01b5924 to b6e74be Compare May 1, 2018 16:50
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@voxpupuli voxpupuli deleted a comment May 1, 2018
@coveralls
Copy link

coveralls commented May 1, 2018

Coverage Status

Coverage increased (+0.6%) to 51.532% when pulling e2f28f6 on dhollinger:rocketchat_plugin into c5ebd2e on voxpupuli:master.

README.md Outdated
@@ -104,7 +104,8 @@ Then configure the webhook to add your Slack Webhook URL:
``` yaml
chatops: true
chatops_service: 'slack' # Required so the app knows that you're sending to Slack.
chatops_channel: '#channel' # deftaults to #general
chatops_url: 'http://slack.webhook/webhook' # mandatory for usage
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

example.com is safe for samples.

Copy link
Member Author

@dhollinger dhollinger May 1, 2018

Choose a reason for hiding this comment

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

True, but slack is always https://hooks.slack.com/<hash>/<hash>/<hash>.

I'll update it with that at least.

##### Rocket.Chat Configuration

You can enable Rocket.Chat notifications for the webhook. You will need a
Rocket.Chat incoming webhook URL and the `rocket-chat-notifier` gem installed.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Aside: Will the runtime dependency provide this during installation, or do we need to plan to provide that another way? And if the runtime dep does, should it for an optional component?

Copy link
Member Author

Choose a reason for hiding this comment

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

As a runtime dependency, the rocket-chat-notifier gem will be installed as a dependency. We could make the gem "optional", but the more you do that, the more work you put on your users to install those "optional" dependencies themselves.

Think of puppetlabs-beaker dependencies, there are so many dependencies for each supported hypervisor that you either install a ton of deps during gem install or put the entire onus on the user to install what he needs (though he may not know what he needs).

I think at this point, we should leave it as a runtime dependency and instead make it optional in the future by providing the ChatOps plugin as a separate gem for puppet_webhook unto itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rnelson0 I should probably add that, right now, the Chatops class doesn't test to see if a dependency exists before loading it, so it expects all dependencies to be there.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Just wanted to understand what the model looks like. Something to keep in mind later if we see dependencies explode.

http_options: @args[:http_options] || {},
icon_emoji: @args[:icon_emoji]).notify
Chatops::Slack.new(
@channel, @url, @user, message, http_options: @args[:http_options] || {}, icon_emoji: @args[:icon_emoji]
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I do feel the vertical stacking esp with pipes and braces is a little easier to digest, here and immediately below, but certainly not required.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll let you and @bastelfreak fight over this one 😃

Copy link
Member

Choose a reason for hiding this comment

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

oh sorry I wasn't clear. I meant something like this:

Chatops::Slack.new(
  bla,
  bla2,
)

that's also enforced via rubocop in our modules, but depending on the current code it doesn't detect it / accepts different styles as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh, ok. I fixed that

message,
http_options: @args[:http_options] || {},
icon_emoji: @args[:icon_emoji]).notify
Chatops::Slack.new(
Copy link
Member

Choose a reason for hiding this comment

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

You might consider moving the require 'plugins/chatops/slack' in here. That will only load the integration you want to use. Not a big deal now, but as you start adding more integrations, you might not want them all loaded all the time.

Chatops::Slack.new(
@channel, @url, @user, message, http_options: @args[:http_options] || {}, icon_emoji: @args[:icon_emoji]
).notify
when 'rocketchat'
Copy link
Member

Choose a reason for hiding this comment

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

Don't forget to require 'plugins/chatops/rocketchat'

Copy link
Member Author

Choose a reason for hiding this comment

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

I knew I forgot something

@voxpupuli voxpupuli deleted a comment May 2, 2018
@rnelson0 rnelson0 dismissed binford2k’s stale review May 2, 2018 18:36

The requested changes were made, but in a different location than the comment.

@dhollinger dhollinger merged commit 0515a4e into voxpupuli:master May 2, 2018
@dhollinger dhollinger deleted the rocketchat_plugin branch May 2, 2018 18:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants