|
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | 16 | require "fluent/plugin/filter" |
17 | | -require "open-uri" |
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 | | - OBSOLETE_PLUGINS_URL = "https://raw.githubusercontent.com/fluent/fluentd-website/master/scripts/obsolete-plugins.yml" |
| 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: OBSOLETE_PLUGINS_URL |
| 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 |
29 | 30 | desc "Raise error if obsolete plugins are detected" |
30 | 31 | config_param :raise_error, :bool, default: false |
31 | 32 |
|
32 | 33 | def configure(conf) |
33 | 34 | super |
34 | 35 |
|
35 | | - @obsolete_plugins = URI.open(@obsolete_plugins_yml) do |io| |
36 | | - YAML.safe_load(io.read) |
37 | | - end |
38 | | - |
39 | | - obsolete_plugins = Gem.loaded_specs.keys & @obsolete_plugins.keys |
40 | | - obsolete_plugins.each do |name| |
41 | | - log.warn("#{name} is obsolete: #{@obsolete_plugins[name].chomp}") |
42 | | - end |
43 | | - if @raise_error && !obsolete_plugins.empty? |
44 | | - raise Fluent::ConfigError, "Detected obsolete plugins" |
45 | | - end |
| 36 | + obsolete_plugins = |
| 37 | + if @obsolete_plugins_yml |
| 38 | + ObsoletePluginsUtils.obsolete_plugins_from_yaml(@obsolete_plugins_yml) |
| 39 | + else |
| 40 | + ObsoletePluginsUtils.obsolete_plugins_from_json(@plugins_json) |
| 41 | + end |
| 42 | + |
| 43 | + ObsoletePluginsUtils.notify(log, obsolete_plugins, raise_error: @raise_error) |
46 | 44 | end |
47 | 45 |
|
48 | 46 | def filter(tag, time, record) |
|
0 commit comments