summaryrefslogtreecommitdiff
path: root/lib/oxidized/hook
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2018-04-25 16:12:44 +0300
committerGitHub <noreply@github.com>2018-04-25 16:12:44 +0300
commit583bc422448a234a215113a15f8a6976c50b2296 (patch)
treeb3f757e6f37aa058a0c80e4ded3ef82553bc98c1 /lib/oxidized/hook
parent9a7d16c00163c421d2c9f3cb2783c76633860336 (diff)
parentdffae0f76656a57da8f5473ce21955638cbe1f7f (diff)
Merge pull request #1296 from wk/the-great-makeover
the great makeover - standardize layout, alignment, indentation
Diffstat (limited to 'lib/oxidized/hook')
-rw-r--r--lib/oxidized/hook/awssns.rb1
-rw-r--r--lib/oxidized/hook/exec.rb5
-rw-r--r--lib/oxidized/hook/githubrepo.rb13
-rw-r--r--lib/oxidized/hook/slackdiff.rb6
-rw-r--r--lib/oxidized/hook/xmppdiff.rb18
5 files changed, 20 insertions, 23 deletions
diff --git a/lib/oxidized/hook/awssns.rb b/lib/oxidized/hook/awssns.rb
index 82c118e..183cd2c 100644
--- a/lib/oxidized/hook/awssns.rb
+++ b/lib/oxidized/hook/awssns.rb
@@ -23,5 +23,4 @@ class AwsSns < Oxidized::Hook
message: message.to_json
)
end
-
end
diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb
index 3f984c2..8a32412 100644
--- a/lib/oxidized/hook/exec.rb
+++ b/lib/oxidized/hook/exec.rb
@@ -23,10 +23,9 @@ class Exec < Oxidized::Hook
@cmd = cfg.cmd
raise "invalid cmd value" unless @cmd.is_a?(String) || @cmd.is_a?(Array)
end
-
rescue RuntimeError => e
raise ArgumentError,
- "#{self.class.name}: configuration invalid: #{e.message}"
+ "#{self.class.name}: configuration invalid: #{e.message}"
end
def run_hook ctx
@@ -45,7 +44,7 @@ class Exec < Oxidized::Hook
def run_cmd! env
pid, status = nil, nil
Timeout.timeout(@timeout) do
- pid = spawn env, @cmd , :unsetenv_others => true
+ pid = spawn env, @cmd, :unsetenv_others => true
pid, status = wait2 pid
unless status.exitstatus.zero?
msg = "#{@cmd.inspect} failed with exit value #{status.exitstatus}"
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb
index 4cae4e6..e077d5d 100644
--- a/lib/oxidized/hook/githubrepo.rb
+++ b/lib/oxidized/hook/githubrepo.rb
@@ -35,21 +35,20 @@ class GithubRepo < Oxidized::Hook
end
Rugged::Commit.create(repo, {
- parents: [repo.head.target, their_branch.target],
- tree: merge_index.write_tree(repo),
- message: "Merge remote-tracking branch '#{their_branch.name}'",
- update_ref: "HEAD"
- })
+ parents: [repo.head.target, their_branch.target],
+ tree: merge_index.write_tree(repo),
+ message: "Merge remote-tracking branch '#{their_branch.name}'",
+ update_ref: "HEAD"
+ })
end
private
def credentials
Proc.new do |url, username_from_url, allowed_types|
-
if cfg.has_key?('username')
git_user = cfg.username
- else
+ else
git_user = username_from_url ? username_from_url : 'git'
end
diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb
index e271d5f..2c5ec14 100644
--- a/lib/oxidized/hook/slackdiff.rb
+++ b/lib/oxidized/hook/slackdiff.rb
@@ -14,8 +14,8 @@ class SlackDiff < Oxidized::Hook
return unless ctx.event.to_s == "post_store"
log "Connecting to slack"
Slack.configure do |config|
- config.token = cfg.token
- config.proxy = cfg.proxy if cfg.has_key?('proxy')
+ config.token = cfg.token
+ config.proxy = cfg.proxy if cfg.has_key?('proxy')
end
client = Slack::Client.new
client.auth_test
@@ -46,7 +46,7 @@ class SlackDiff < Oxidized::Hook
msg = format(cfg.message, :node => ctx.node.name.to_s, :group => ctx.node.group.to_s, :commitref => ctx.commitref, :model => ctx.node.model.class.name.to_s.downcase)
log msg
log "Posting message to #{cfg.channel}"
- client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true)
+ client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true)
end
log "Finished"
end
diff --git a/lib/oxidized/hook/xmppdiff.rb b/lib/oxidized/hook/xmppdiff.rb
index 52cc0e0..6acb172 100644
--- a/lib/oxidized/hook/xmppdiff.rb
+++ b/lib/oxidized/hook/xmppdiff.rb
@@ -30,25 +30,25 @@ class XMPPDiff < Oxidized::Hook
sleep 1
client.auth(cfg.password)
sleep 1
-
+
log "Connected"
-
+
m = Jabber::MUC::SimpleMUCClient.new(client)
m.join(cfg.channel + "/" + cfg.nick)
-
+
log "Joined"
-
+
title = "#{ctx.node.name} #{ctx.node.group} #{ctx.node.model.class.name.to_s.downcase}"
log "Posting diff as snippet to #{cfg.channel}"
-
+
m.say(title + "\n\n" + diff[:patch].lines.to_a[4..-1].join)
-
+
sleep 1
-
+
client.close
-
+
log "Finished"
-
+
end
end
rescue Timeout::Error