mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
parent
7f0b70aaba
commit
4d7549f5f7
4 changed files with 22 additions and 10 deletions
|
@ -6,6 +6,8 @@ require "logstash/logging"
|
|||
require "logstash/util/password"
|
||||
require "logstash/version"
|
||||
require "logstash/environment"
|
||||
require "logstash/util/plugin_version"
|
||||
|
||||
LogStash::Environment.load_locale!
|
||||
|
||||
# This module is meant as a mixin to classes wishing to be configurable from
|
||||
|
@ -212,11 +214,7 @@ module LogStash::Config::Mixin
|
|||
specification = Gem::Specification.find_by_name(plugin_gem_name)
|
||||
major, minor, patch = specification.version.segments
|
||||
|
||||
return {
|
||||
:major => major,
|
||||
:minor => minor,
|
||||
:patch => patch
|
||||
}
|
||||
return LogStash::Util::PluginVersion.new(major, minor, patch)
|
||||
end
|
||||
|
||||
def plugin_gem_name
|
||||
|
@ -226,8 +224,8 @@ module LogStash::Config::Mixin
|
|||
def print_version_notice
|
||||
return true if @@version_notice_given
|
||||
|
||||
if plugin_version[:major] < 1
|
||||
if plugin_version[:minor] == 9
|
||||
if plugin_version.major < 1
|
||||
if plugin_version.minor == 9
|
||||
@logger.warn(I18n.t("logstash.plugin.version.0-9-x",
|
||||
:type => @plugin_type,
|
||||
:name => @config_name,
|
||||
|
|
1
lib/logstash/util/plugin_version.rb
Normal file
1
lib/logstash/util/plugin_version.rb
Normal file
|
@ -0,0 +1 @@
|
|||
LogStash::Util::PluginVersion = Struct.new(:major, :minor, :patch)
|
|
@ -69,7 +69,7 @@ describe LogStash::Plugin do
|
|||
end
|
||||
|
||||
it "doesnt show the version notice more than once" do
|
||||
class LogStash::Filters::Stromae < LogStash::Filters::Base
|
||||
one_notice = Class.new(LogStash::Filters::Base) do
|
||||
config_name "stromae"
|
||||
end
|
||||
|
||||
|
@ -81,8 +81,8 @@ describe LogStash::Plugin do
|
|||
.once
|
||||
.with(/Using version 0.1.x/)
|
||||
|
||||
LogStash::Filters::Stromae.validate({})
|
||||
LogStash::Filters::Stromae.validate({})
|
||||
one_notice.validate({})
|
||||
one_notice.validate({})
|
||||
end
|
||||
|
||||
it 'logs an error if the plugin use the milestone option' do
|
||||
|
|
13
spec/util/plugin_version_spec.rb
Normal file
13
spec/util/plugin_version_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require "logstash/util/plugin_version"
|
||||
|
||||
describe LogStash::Util::PluginVersion do
|
||||
subject { LogStash::Util::PluginVersion }
|
||||
|
||||
it 'contains the semver parts of a plugin version' do
|
||||
version = subject.new(1, 2, 3)
|
||||
|
||||
expect(version.major).to eq(1)
|
||||
expect(version.minor).to eq(2)
|
||||
expect(version.patch).to eq(3)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue