slackistrano 3.8.4 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +4 -3
- data/lib/slackistrano/capistrano.rb +3 -12
- data/lib/slackistrano/messaging/base.rb +0 -1
- data/lib/slackistrano/version.rb +1 -1
- metadata +2 -5
- data/lib/slackistrano/messaging/deprecated.rb +0 -75
- data/spec/messaging/deprecated_spec.rb +0 -79
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f28f0c81b8d8772f9b77f26c0f3f069ea770630f94c63d91affc4724e397415
|
4
|
+
data.tar.gz: 49771347f5329cff33061b3fe4a83c2b785d7922dc57f420b766a0b9515798fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 578f583688d88ac3c0092d8f4da674bae4b562c58bb0c120d24cd4c77e38b744e8eb0310125a148d7bcf2c03beef70b8f2968051121a372db160b9c9c6ffb18c
|
7
|
+
data.tar.gz: 83f90a56bd3e2a067fd9437417e2fef5ef0853bf59d56fc87160982f482acd31022cb7a82d91018552396cc963836ea8e5a0f991e7533ea8321a53b7ee1651e8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# Slackistrano Change Log
|
2
2
|
|
3
|
-
|
3
|
+
4.0.0
|
4
4
|
-----
|
5
5
|
|
6
|
-
-
|
6
|
+
- **BREAKING:** The Messaging::Deprecated has been removed. You must use
|
7
|
+
the new configuration options as specified in the README.
|
7
8
|
|
8
9
|
3.8.3
|
9
10
|
-----
|
10
11
|
|
11
|
-
-
|
12
|
+
- Fix improper boolean check when using not using slackbot and channels are empty [#90]
|
12
13
|
|
13
14
|
3.8.2
|
14
15
|
-----
|
@@ -17,21 +17,12 @@ module Slackistrano
|
|
17
17
|
def initialize(env)
|
18
18
|
@env = env
|
19
19
|
config = fetch(:slackistrano, {})
|
20
|
-
@messaging =
|
21
|
-
when false
|
22
|
-
Messaging::Null.new
|
23
|
-
when -> (o) { o.empty? }
|
24
|
-
klass = Messaging::Deprecated.new(
|
25
|
-
env: @env,
|
26
|
-
team: fetch(:slack_team),
|
27
|
-
channel: fetch(:slack_channel),
|
28
|
-
token: fetch(:slack_token),
|
29
|
-
webhook: fetch(:slack_webhook)
|
30
|
-
)
|
31
|
-
else
|
20
|
+
@messaging = if config
|
32
21
|
opts = config.dup.merge(env: @env)
|
33
22
|
klass = opts.delete(:klass) || Messaging::Default
|
34
23
|
klass.new(opts)
|
24
|
+
else
|
25
|
+
Messaging::Null.new
|
35
26
|
end
|
36
27
|
end
|
37
28
|
|
data/lib/slackistrano/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hallstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -86,7 +86,6 @@ files:
|
|
86
86
|
- lib/slackistrano/capistrano.rb
|
87
87
|
- lib/slackistrano/messaging/base.rb
|
88
88
|
- lib/slackistrano/messaging/default.rb
|
89
|
-
- lib/slackistrano/messaging/deprecated.rb
|
90
89
|
- lib/slackistrano/messaging/helpers.rb
|
91
90
|
- lib/slackistrano/messaging/null.rb
|
92
91
|
- lib/slackistrano/tasks/slack.rake
|
@@ -95,7 +94,6 @@ files:
|
|
95
94
|
- spec/capistrano_deploy_stubs.rake
|
96
95
|
- spec/disabling_posting_to_slack_spec.rb
|
97
96
|
- spec/dry_run_spec.rb
|
98
|
-
- spec/messaging/deprecated_spec.rb
|
99
97
|
- spec/messaging/helpers_spec.rb
|
100
98
|
- spec/messaging/null_spec.rb
|
101
99
|
- spec/nil_payload_spec.rb
|
@@ -129,7 +127,6 @@ test_files:
|
|
129
127
|
- spec/capistrano_deploy_stubs.rake
|
130
128
|
- spec/disabling_posting_to_slack_spec.rb
|
131
129
|
- spec/dry_run_spec.rb
|
132
|
-
- spec/messaging/deprecated_spec.rb
|
133
130
|
- spec/messaging/helpers_spec.rb
|
134
131
|
- spec/messaging/null_spec.rb
|
135
132
|
- spec/nil_payload_spec.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Slackistrano
|
2
|
-
module Messaging
|
3
|
-
class Deprecated < Base
|
4
|
-
|
5
|
-
def initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil)
|
6
|
-
run_locally do
|
7
|
-
warn("[slackistrano] You are using an outdated configuration that will be removed soon.")
|
8
|
-
warn("[slackistrano] Please upgrade soon! <https://github.com/phallstrom/slackistrano>")
|
9
|
-
end
|
10
|
-
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def icon_url
|
15
|
-
fetch("slack_icon_url".to_sym) || super
|
16
|
-
end
|
17
|
-
|
18
|
-
def icon_emoji
|
19
|
-
fetch("slack_icon_emoji".to_sym) || super
|
20
|
-
end
|
21
|
-
|
22
|
-
def username
|
23
|
-
fetch("slack_username".to_sym) || super
|
24
|
-
end
|
25
|
-
|
26
|
-
def deployer
|
27
|
-
fetch("slack_deploy_user".to_sym) || super
|
28
|
-
end
|
29
|
-
|
30
|
-
def channels_for(action)
|
31
|
-
fetch("slack_channel_#{action}".to_sym) || super
|
32
|
-
end
|
33
|
-
|
34
|
-
def payload_for_updating
|
35
|
-
make_message(__method__, super)
|
36
|
-
end
|
37
|
-
|
38
|
-
def payload_for_reverting
|
39
|
-
make_message(__method__, super)
|
40
|
-
end
|
41
|
-
|
42
|
-
def payload_for_updated
|
43
|
-
make_message(__method__, super.merge(color: 'good'))
|
44
|
-
end
|
45
|
-
|
46
|
-
def payload_for_reverted
|
47
|
-
make_message(__method__, super.merge(color: 'warning'))
|
48
|
-
end
|
49
|
-
|
50
|
-
def payload_for_failed
|
51
|
-
make_message(__method__, super.merge(color: 'danger'))
|
52
|
-
end
|
53
|
-
|
54
|
-
private ##################################################
|
55
|
-
|
56
|
-
def make_message(method, options={})
|
57
|
-
action = method.to_s.sub('payload_for_', '')
|
58
|
-
|
59
|
-
return nil unless fetch("slack_run".to_sym, true) && fetch("slack_run_#{action}".to_sym, true)
|
60
|
-
|
61
|
-
attachment = options.merge({
|
62
|
-
title: fetch(:"slack_title_#{action}"),
|
63
|
-
pretext: fetch(:"slack_pretext_#{action}"),
|
64
|
-
text: fetch(:"slack_msg_#{action}", options[:text]),
|
65
|
-
fields: fetch(:"slack_fields_#{action}", []),
|
66
|
-
fallback: fetch(:"slack_fallback_#{action}"),
|
67
|
-
mrkdwn_in: [:text, :pretext]
|
68
|
-
}).reject{|k, v| v.nil? }
|
69
|
-
|
70
|
-
{attachments: [attachment]}
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Slackistrano::Messaging::Deprecated do
|
4
|
-
before(:each) do
|
5
|
-
set :slackistrano, {}
|
6
|
-
end
|
7
|
-
|
8
|
-
%w[updating reverting updated reverted failed].each do |stage|
|
9
|
-
it "posts to slack on slack:deploy:#{stage}" do
|
10
|
-
set :slack_webhook, -> { "..." }
|
11
|
-
set :slack_run, ->{ true }
|
12
|
-
set "slack_run_#{stage}".to_sym, ->{ true }
|
13
|
-
expect_any_instance_of(Slackistrano::Capistrano).to receive(:post)
|
14
|
-
Rake::Task["slack:deploy:#{stage}"].execute
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not post to slack on slack:deploy:#{stage} when disabled" do
|
18
|
-
set :slack_webhook, -> { "..." }
|
19
|
-
set :slack_run, ->{ true }
|
20
|
-
set "slack_run_#{stage}".to_sym, ->{ false }
|
21
|
-
expect_any_instance_of(Slackistrano::Capistrano).not_to receive(:post)
|
22
|
-
Rake::Task["slack:deploy:#{stage}"].execute
|
23
|
-
end
|
24
|
-
|
25
|
-
it "does not post to slack on slack:deploy:#{stage} when disabled globally" do
|
26
|
-
set :slack_webhook, -> { "..." }
|
27
|
-
set :slack_run, ->{ false }
|
28
|
-
set "slack_run_#{stage}".to_sym, ->{ true }
|
29
|
-
expect_any_instance_of(Slackistrano::Capistrano).not_to receive(:post)
|
30
|
-
Rake::Task["slack:deploy:#{stage}"].execute
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
[ # stage, color, channel
|
35
|
-
['updating', nil, nil],
|
36
|
-
['reverting', nil, nil],
|
37
|
-
['updated', 'good', nil],
|
38
|
-
['reverted', 'warning', nil],
|
39
|
-
['failed', 'danger', nil],
|
40
|
-
['updating', nil, 'starting_channel'],
|
41
|
-
['updated', 'good', 'finished_channel'],
|
42
|
-
['reverted', 'warning', 'rollback_channel'],
|
43
|
-
['failed', 'danger', 'failed_channel'],
|
44
|
-
].each do |stage, color, channel_for_stage|
|
45
|
-
|
46
|
-
it "calls post_to_slack with the right arguments for stage=#{stage}, color=#{color}, channel_for_stage=#{channel_for_stage}" do
|
47
|
-
set :slack_run, ->{ true }
|
48
|
-
set "slack_run_#{stage}".to_sym, -> { true }
|
49
|
-
set :slack_team, -> { 'team' }
|
50
|
-
set :slack_token, -> { 'token' }
|
51
|
-
set :slack_webhook, -> { 'webhook' }
|
52
|
-
set :slack_channel, -> { 'channel' }
|
53
|
-
set :slack_icon_url, -> { 'http://icon.url' }
|
54
|
-
set :slack_icon_emoji, -> { ':emoji:' }
|
55
|
-
set "slack_msg_#{stage}".to_sym, -> { 'text message' }
|
56
|
-
|
57
|
-
set "slack_channel_#{stage}".to_sym, -> { channel_for_stage }
|
58
|
-
expected_channel = channel_for_stage || 'channel'
|
59
|
-
|
60
|
-
attachment = {
|
61
|
-
text: 'text message',
|
62
|
-
color: color,
|
63
|
-
fields: [],
|
64
|
-
fallback: nil,
|
65
|
-
mrkdwn_in: [:text, :pretext]
|
66
|
-
}.reject{|k,v| v.nil?}
|
67
|
-
|
68
|
-
expect_any_instance_of(Slackistrano::Capistrano).to receive(:post_to_slack).with({
|
69
|
-
channel: expected_channel,
|
70
|
-
username: 'Slackistrano',
|
71
|
-
icon_url: 'http://icon.url',
|
72
|
-
icon_emoji: ':emoji:',
|
73
|
-
attachments: [attachment]
|
74
|
-
}).and_return(double(code: '200'))
|
75
|
-
Rake::Task["slack:deploy:#{stage}"].execute
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|