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

Commit

Permalink
rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed May 1, 2018
1 parent 4b75bac commit d6c9970
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions lib/helpers/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,28 @@ def generate_types(environment)
end

def notification(message)
if settings.chatops || settings.slack_webhook
slack_settings if settings.chatops == false && settings.slack_webhook != false
PuppetWebhook::Chatops.new(settings.chatops_service,
settings.chatops_url,
settings.chatops_channel,
settings.chatops_user,
settings.chatops_options).notify(message)
end
return unless settings.chatops || settings.slack_webhook
slack_settings if settings.chatops == false && settings.slack_webhook != false
PuppetWebhook::Chatops.new(settings.chatops_service,
settings.chatops_url,
settings.chatops_channel,
settings.chatops_user,
settings.chatops_options).notify(message)
end

# Deprecated
# TODO: Remove in release 3.0.0
def slack_settings
settings.chatops_service = 'slack'
LOGGER.warn("settings.slack_webhook is deprecated and will be removed in puppet_webhook 3.0.0")
LOGGER.warn('settings.slack_webhook is deprecated and will be removed in puppet_webhook 3.0.0')
settings.chatops_url = settings.slack_webhook
LOGGER.warn("settings.slack_user is deprecated and will be removed in puppet_webhook 3.0.0")
LOGGER.warn('settings.slack_user is deprecated and will be removed in puppet_webhook 3.0.0')
settings.chatops_user = settings.slack_user
LOGGER.warn("settings.slack_channel is deprecated and will be removed in puppet_webhook 3.0.0")
LOGGER.warn('settings.slack_channel is deprecated and will be removed in puppet_webhook 3.0.0')
settings.chatops_channel = settings.slack_channel
LOGGER.warn("settings.slack_emoji is deprecated and will be removed in puppet_webhook 3.0.0")
LOGGER.warn('settings.slack_emoji is deprecated and will be removed in puppet_webhook 3.0.0')
settings.chatops_options[:icon_emoji] = settings.slack_emoji
LOGGER.warn("settings.slack_proxy_url is deprecated and will be removed in puppet_webhook 3.0.0")
LOGGER.warn('settings.slack_proxy_url is deprecated and will be removed in puppet_webhook 3.0.0')
settings.chatops_options[:http_options] = if settings.slack_proxy_url
slack_proxy
else
Expand All @@ -101,9 +100,9 @@ def slack_settings
def slack_proxy
uri = URI(settings.slack_proxy_url)
http_options = {
proxy_address: uri.hostname,
proxy_port: uri.port,
proxy_from_env: false
proxy_address: uri.hostname,
proxy_port: uri.port,
proxy_from_env: false
}
http_options
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/plugins/webhook_chatops_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
expect(PuppetWebhook::Chatops.notify).to eq(notification_data)
end
end
end
end

0 comments on commit d6c9970

Please sign in to comment.