fluent-plugin-obsolete-plugins 0.1.1 → 0.2.0
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/README.md +40 -4
- data/fluent-plugin-obsolete-plugins.gemspec +1 -1
- data/lib/fluent/plugin/filter_obsolete_plugins.rb +19 -15
- data/lib/fluent/plugin/in_obsolete_plugins.rb +30 -0
- data/lib/fluent/plugin/obsolete_plugins_utils.rb +40 -0
- data/test/fixtures/invalid.json +11 -0
- data/test/fixtures/plugins.json +13147 -0
- data/test/helper.rb +0 -1
- data/test/plugin/test_filter_obsolete_plugins.rb +139 -36
- data/test/plugin/test_in_obsolete_plugins.rb +115 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64c35dab27cb19ba6b8f33edd023c6dbcc100256b0f372e7f51f8d4dc99a3197
|
4
|
+
data.tar.gz: aedff69e17e8d8ce189920ee3249e5385b3dbde50157b8b83630e40e276ad8cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '028c5a09fc99fac1c8be4a36c4ab1d2bdbd7c88178336771696d6e6e22393b6e2de14d42c7cfc2509a1e12b01b2204845ab1b342f0007badd75e46b96c7cd1b2'
|
7
|
+
data.tar.gz: 1440e86c8bc39de6bcd6a68624254a624d4d2d235460430c22dc0ae1ded7cf54eb985b1662101f3ab7ebd25b0faf3ffd9e101de8909ef1df8ec1f79784a7ad2d
|
data/README.md
CHANGED
@@ -30,13 +30,49 @@ $ bundle
|
|
30
30
|
|
31
31
|
## Configuration
|
32
32
|
|
33
|
-
###
|
33
|
+
### Filter plugin
|
34
34
|
|
35
|
-
|
35
|
+
#### plugins_json (string) (optional)
|
36
36
|
|
37
|
-
|
37
|
+
Path to `plugins.json`.
|
38
38
|
|
39
|
-
|
39
|
+
Default value: `https://raw.githubusercontent.com/fluent/fluentd-website/master/scripts/plugins.json`.
|
40
|
+
|
41
|
+
#### Deprecated: obsolete_plugins_yml (string) (optional)
|
42
|
+
|
43
|
+
Path to `obsolete-plugins.yml`. This parameter is deprecated. Please use `plugins_json` parameter instead.
|
44
|
+
|
45
|
+
Default value: `nil`
|
46
|
+
|
47
|
+
#### timeout (integer) (optional)
|
48
|
+
|
49
|
+
Timeout to read data of obsolete plugins.
|
50
|
+
If it occurs timeout, it just skips to detect obsolete plugins.
|
51
|
+
|
52
|
+
Default value: `5`
|
53
|
+
|
54
|
+
#### raise_error (bool) (optional)
|
55
|
+
|
56
|
+
Raise error if obsolete plugins are detected
|
57
|
+
|
58
|
+
Default value: `false`.
|
59
|
+
|
60
|
+
### Input plugin
|
61
|
+
|
62
|
+
#### plugins_json (string) (optional)
|
63
|
+
|
64
|
+
Path to `plugins.json`.
|
65
|
+
|
66
|
+
Default value: `https://raw.githubusercontent.com/fluent/fluentd-website/master/scripts/plugins.json`.
|
67
|
+
|
68
|
+
#### timeout (integer) (optional)
|
69
|
+
|
70
|
+
Timeout to read data of obsolete plugins.
|
71
|
+
If it occurs timeout, it just skips to detect obsolete plugins.
|
72
|
+
|
73
|
+
Default value: `5`
|
74
|
+
|
75
|
+
#### raise_error (bool) (optional)
|
40
76
|
|
41
77
|
Raise error if obsolete plugins are detected
|
42
78
|
|
@@ -14,35 +14,39 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
16
|
require "fluent/plugin/filter"
|
17
|
-
require "
|
18
|
-
require "yaml"
|
17
|
+
require "fluent/plugin/obsolete_plugins_utils"
|
19
18
|
|
20
19
|
module Fluent
|
21
20
|
module Plugin
|
22
21
|
class ObsoletePluginsFilter < Fluent::Plugin::Filter
|
23
22
|
Fluent::Plugin.register_filter("obsolete_plugins", self)
|
24
23
|
|
25
|
-
|
24
|
+
PLUGINS_JSON_URL = "https://raw.githubusercontent.com/fluent/fluentd-website/master/scripts/plugins.json"
|
26
25
|
|
27
26
|
desc "Path to obsolete-plugins.yml"
|
28
|
-
config_param :obsolete_plugins_yml, :string, default:
|
27
|
+
config_param :obsolete_plugins_yml, :string, default: nil, deprecated: "use plugins_json parameter instead"
|
28
|
+
desc "Path to plugins.json"
|
29
|
+
config_param :plugins_json, :string, default: PLUGINS_JSON_URL
|
30
|
+
desc "Timeout value to read data of obsolete plugins"
|
31
|
+
config_param :timeout, :integer, default: 5
|
29
32
|
desc "Raise error if obsolete plugins are detected"
|
30
33
|
config_param :raise_error, :bool, default: false
|
31
34
|
|
32
35
|
def configure(conf)
|
33
36
|
super
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
obsolete_plugins =
|
39
|
+
if @obsolete_plugins_yml
|
40
|
+
ObsoletePluginsUtils.obsolete_plugins_from_yaml(@obsolete_plugins_yml, timeout: @timeout)
|
41
|
+
else
|
42
|
+
ObsoletePluginsUtils.obsolete_plugins_from_json(@plugins_json, timeout: @timeout)
|
43
|
+
end
|
44
|
+
|
45
|
+
ObsoletePluginsUtils.notify(log, obsolete_plugins, raise_error: @raise_error)
|
46
|
+
rescue Fluent::ConfigError
|
47
|
+
raise
|
48
|
+
rescue => e
|
49
|
+
log.info("Failed to notify obsolete plugins", error: e)
|
46
50
|
end
|
47
51
|
|
48
52
|
def filter(tag, time, record)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "fluent/plugin/input"
|
2
|
+
require "fluent/plugin/obsolete_plugins_utils"
|
3
|
+
|
4
|
+
module Fluent
|
5
|
+
module Plugin
|
6
|
+
class ObsoletePluginsInput < Fluent::Plugin::Input
|
7
|
+
Fluent::Plugin.register_input("obsolete_plugins", self)
|
8
|
+
|
9
|
+
PLUGINS_JSON_URL = "https://raw.githubusercontent.com/fluent/fluentd-website/master/scripts/plugins.json"
|
10
|
+
|
11
|
+
desc "Path to plugins.json"
|
12
|
+
config_param :plugins_json, :string, default: PLUGINS_JSON_URL
|
13
|
+
desc "Timeout value to read data of obsolete plugins"
|
14
|
+
config_param :timeout, :integer, default: 5
|
15
|
+
desc "Raise error if obsolete plugins are detected"
|
16
|
+
config_param :raise_error, :bool, default: false
|
17
|
+
|
18
|
+
def configure(conf)
|
19
|
+
super
|
20
|
+
|
21
|
+
obsolete_plugins = ObsoletePluginsUtils.obsolete_plugins_from_json(@plugins_json, timeout: @timeout)
|
22
|
+
ObsoletePluginsUtils.notify(log, obsolete_plugins, raise_error: @raise_error)
|
23
|
+
rescue Fluent::ConfigError
|
24
|
+
raise
|
25
|
+
rescue => e
|
26
|
+
log.info("Failed to notify obsolete plugins", error: e)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "fluent/config/error"
|
2
|
+
require "open-uri"
|
3
|
+
require "yaml"
|
4
|
+
require "json"
|
5
|
+
require "timeout"
|
6
|
+
|
7
|
+
class Fluent::Plugin::ObsoletePluginsUtils
|
8
|
+
def self.obsolete_plugins_from_yaml(url, timeout: 5)
|
9
|
+
Timeout.timeout(timeout) do
|
10
|
+
URI.open(url) do |io|
|
11
|
+
YAML.safe_load(io.read)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.obsolete_plugins_from_json(url, timeout: 5)
|
17
|
+
plugins = Timeout.timeout(timeout) do
|
18
|
+
URI.open(url) do |io|
|
19
|
+
# io.read causes Encoding::UndefinedConversionError with UTF-8 data when Ruby is started with "-Eascii-8bit:ascii-8bit".
|
20
|
+
# It set the proper encoding to avoid the error.
|
21
|
+
io.set_encoding("UTF-8", "UTF-8")
|
22
|
+
JSON.parse(io.read)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
plugins.select { |plugin| plugin["obsolete"] }.reduce({}) do |result, plugin|
|
26
|
+
result[plugin["name"]] = plugin["note"]
|
27
|
+
result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.notify(logger, obsolete_plugins, raise_error: false)
|
32
|
+
plugins = Gem.loaded_specs.keys & obsolete_plugins.keys
|
33
|
+
plugins.each do |name|
|
34
|
+
logger.warn("#{name} is obsolete: #{obsolete_plugins[name].chomp}")
|
35
|
+
end
|
36
|
+
if raise_error && !plugins.empty?
|
37
|
+
raise Fluent::ConfigError, "Detected obsolete plugins"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"obsolete": null,
|
4
|
+
"note": null,
|
5
|
+
"name": "fluent-plugin-s3",
|
6
|
+
"info": "Amazon S3 output plugin for Fluentd event collector",
|
7
|
+
"authors": "Sadayuki Furuhashi, Masahiro Nakagawa",
|
8
|
+
"version": "1.8.3",
|
9
|
+
"downloads": 134522742,
|
10
|
+
"homepage_uri": "https://github.com/fluent/fluent-plugin-s3",
|
11
|
+
"source_code_uri": null
|