fluent-plugin-slack 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/example.conf +2 -2
- data/lib/fluent/plugin/out_slack.rb +27 -15
- data/test/plugin/test_out_slack.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 184b33be08e986aed0759111ca47da646a170b4d
|
4
|
+
data.tar.gz: 72fb479769709a04b749d4cf6391f4d1fe86b3c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab882482f1f5735a837444220f96ecbc5c68b4b9ff660007c3b4189ef0da812598e2dc8bab147c810a5ff6e2a3724709d95e49f6449ae6a00fb34382d985d7ec
|
7
|
+
data.tar.gz: 2b2f9de2865c86ee853a67a512b998d8e29e39081d95385472511f3303e42f8f7940d31c6d14b63945f8055e0d44b02757f711402def1358e96c3cb9d46c78a7
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.6
|
data/example.conf
CHANGED
@@ -86,7 +86,7 @@ DESC
|
|
86
86
|
config_param :https_proxy, :string, default: nil
|
87
87
|
|
88
88
|
desc "channel to send messages (without first '#')."
|
89
|
-
config_param :channel, :string
|
89
|
+
config_param :channel, :string, default: nil
|
90
90
|
desc <<-DESC
|
91
91
|
Keys used to format channel.
|
92
92
|
%s will be replaced with value specified by channel_keys if this option is used.
|
@@ -130,11 +130,13 @@ DESC
|
|
130
130
|
def configure(conf)
|
131
131
|
conf['time_format'] ||= '%H:%M:%S' # old version compatiblity
|
132
132
|
conf['localtime'] ||= true unless conf['utc']
|
133
|
-
|
133
|
+
|
134
134
|
super
|
135
135
|
|
136
|
-
|
137
|
-
|
136
|
+
if @channel
|
137
|
+
@channel = URI.unescape(@channel) # old version compatibility
|
138
|
+
@channel = '#' + @channel unless @channel.start_with?('#')
|
139
|
+
end
|
138
140
|
|
139
141
|
if @webhook_url
|
140
142
|
if @webhook_url.empty?
|
@@ -148,6 +150,10 @@ DESC
|
|
148
150
|
if @slackbot_url.empty?
|
149
151
|
raise Fluent::ConfigError.new("`slackbot_url` is an empty string")
|
150
152
|
end
|
153
|
+
if @channel.nil?
|
154
|
+
raise Fluent::ConfigError.new("`channel` parameter required for Slackbot Remote Control")
|
155
|
+
end
|
156
|
+
|
151
157
|
if @username or @color or @icon_emoji or @icon_url
|
152
158
|
log.warn "out_slack: `username`, `color`, `icon_emoji`, `icon_url` parameters are not available for Slackbot Remote Control"
|
153
159
|
end
|
@@ -159,6 +165,10 @@ DESC
|
|
159
165
|
if @token.empty?
|
160
166
|
raise Fluent::ConfigError.new("`token` is an empty string")
|
161
167
|
end
|
168
|
+
if @channel.nil?
|
169
|
+
raise Fluent::ConfigError.new("`channel` parameter required for Slack WebApi")
|
170
|
+
end
|
171
|
+
|
162
172
|
@slack = Fluent::SlackClient::WebApi.new
|
163
173
|
else
|
164
174
|
raise Fluent::ConfigError.new("One of `webhook_url` or `slackbot_url`, or `token` is required")
|
@@ -184,7 +194,7 @@ DESC
|
|
184
194
|
raise Fluent::ConfigError, "string specifier '%s' for `title` and `title_keys` specification mismatch"
|
185
195
|
end
|
186
196
|
end
|
187
|
-
if @channel_keys
|
197
|
+
if @channel && @channel_keys
|
188
198
|
begin
|
189
199
|
@channel % (['1'] * @channel_keys.length)
|
190
200
|
rescue ArgumentError
|
@@ -288,13 +298,14 @@ DESC
|
|
288
298
|
fields.values.map(&:title).join(' ')
|
289
299
|
end
|
290
300
|
|
291
|
-
{
|
292
|
-
channel: channel,
|
301
|
+
msg = {
|
293
302
|
attachments: [{
|
294
303
|
:fallback => fallback_text, # fallback is the message shown on popup
|
295
304
|
:fields => fields.values.map(&:to_h)
|
296
305
|
}.merge(common_attachment)],
|
297
|
-
}
|
306
|
+
}
|
307
|
+
msg.merge!(channel: channel) if channel
|
308
|
+
msg.merge!(common_payload)
|
298
309
|
end
|
299
310
|
end
|
300
311
|
|
@@ -306,13 +317,14 @@ DESC
|
|
306
317
|
messages[channel] << "#{build_message(record)}\n"
|
307
318
|
end
|
308
319
|
messages.map do |channel, text|
|
309
|
-
{
|
310
|
-
channel: channel,
|
320
|
+
msg = {
|
311
321
|
attachments: [{
|
312
322
|
:fallback => text,
|
313
323
|
:text => text,
|
314
324
|
}.merge(common_attachment)],
|
315
|
-
}
|
325
|
+
}
|
326
|
+
msg.merge!(channel: channel) if channel
|
327
|
+
msg.merge!(common_payload)
|
316
328
|
end
|
317
329
|
end
|
318
330
|
|
@@ -324,10 +336,9 @@ DESC
|
|
324
336
|
messages[channel] << "#{build_message(record)}\n"
|
325
337
|
end
|
326
338
|
messages.map do |channel, text|
|
327
|
-
{
|
328
|
-
|
329
|
-
|
330
|
-
}.merge(common_payload)
|
339
|
+
msg = {text: text}
|
340
|
+
msg.merge!(channel: channel) if channel
|
341
|
+
msg.merge!(common_payload)
|
331
342
|
end
|
332
343
|
end
|
333
344
|
|
@@ -344,6 +355,7 @@ DESC
|
|
344
355
|
end
|
345
356
|
|
346
357
|
def build_channel(record)
|
358
|
+
return nil if @channel.nil?
|
347
359
|
return @channel unless @channel_keys
|
348
360
|
|
349
361
|
values = fetch_keys(record, @channel_keys)
|
@@ -114,15 +114,30 @@ class SlackOutputTest < Test::Unit::TestCase
|
|
114
114
|
create_driver(%[channel foo\nwebhook_url])
|
115
115
|
end
|
116
116
|
|
117
|
-
#
|
117
|
+
# webhook without channel (it works because webhook has a default channel)
|
118
|
+
assert_nothing_raised do
|
119
|
+
create_driver(%[webhook_url https://example.com/path/to/webhook])
|
120
|
+
end
|
121
|
+
|
122
|
+
# slackbot_url is an empty string
|
118
123
|
assert_raise(Fluent::ConfigError) do
|
119
124
|
create_driver(%[channel foo\nslackbot_url])
|
120
125
|
end
|
121
126
|
|
127
|
+
# slackbot without channel
|
128
|
+
assert_raise(Fluent::ConfigError) do
|
129
|
+
create_driver(%[slackbot_url https://example.com/path/to/slackbot])
|
130
|
+
end
|
131
|
+
|
122
132
|
# token is an empty string
|
123
133
|
assert_raise(Fluent::ConfigError) do
|
124
134
|
create_driver(%[channel foo\ntoken])
|
125
135
|
end
|
136
|
+
|
137
|
+
# slack webapi token without channel
|
138
|
+
assert_raise(Fluent::ConfigError) do
|
139
|
+
create_driver(%[token some_token])
|
140
|
+
end
|
126
141
|
end
|
127
142
|
|
128
143
|
def test_timezone_configure
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke SOGAWA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-05-
|
12
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|