mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
refactor list of license_types
DRY up the list of license types as there were 10 places that listed the types explicitly Fixes #11407
This commit is contained in:
parent
f3a24217c2
commit
25a0ecddac
8 changed files with 12 additions and 15 deletions
|
@ -18,8 +18,6 @@ module LogStash
|
|||
|
||||
attr_reader :last_updated
|
||||
|
||||
LICENSE_TYPES = :trial, :basic, :standard, :gold, :platinum
|
||||
|
||||
def initialize (reader, feature, refresh_period=30, refresh_unit=TimeUnit::SECONDS)
|
||||
@license_reader = reader
|
||||
@feature = feature
|
||||
|
|
|
@ -9,11 +9,11 @@ java_import java.util.concurrent.TimeUnit
|
|||
|
||||
module LogStash
|
||||
module LicenseChecker
|
||||
LICENSE_TYPES = ['trial', 'basic', 'standard', 'gold', 'platinum']
|
||||
|
||||
class XPackInfo
|
||||
include LogStash::Util::Loggable
|
||||
|
||||
LICENSE_TYPES = :trial, :basic, :standard, :gold, :platinum
|
||||
|
||||
def initialize(license, features = nil, installed=true, failed = false)
|
||||
@license = license
|
||||
@installed = installed
|
||||
|
|
|
@ -11,7 +11,6 @@ module LogStash module Monitoring
|
|||
include LogStash::LicenseChecker::Licensed
|
||||
include LogStash::Helpers::ElasticsearchOptions
|
||||
include LogStash::Util::Loggable
|
||||
VALID_LICENSES = %w(basic trial standard gold platinum)
|
||||
FEATURE = 'monitoring'
|
||||
|
||||
def initialize(pipeline_config, agent)
|
||||
|
@ -68,7 +67,7 @@ module LogStash module Monitoring
|
|||
:log_level => :error,
|
||||
:log_message => 'Monitoring is not available: License information is currently unavailable. Please make sure you have added your production elasticsearch connection info in the xpack.monitoring.elasticsearch settings.'
|
||||
}
|
||||
elsif !xpack_info.license_one_of?(VALID_LICENSES)
|
||||
elsif !xpack_info.license_one_of?(::LogStash::LicenseChecker::LICENSE_TYPES)
|
||||
{
|
||||
:state => :error,
|
||||
:log_level => :error,
|
||||
|
|
|
@ -20,7 +20,7 @@ LogStash::PLUGIN_REGISTRY.add(:universal, "monitoring", LogStash::MonitoringExte
|
|||
LogStash::PLUGIN_REGISTRY.add(:universal, "config_management", LogStash::ConfigManagement::Extension)
|
||||
|
||||
license_levels = Hash.new
|
||||
license_levels.default = ["basic", "trial", "standard", "gold", "platinum"]
|
||||
license_levels.default = LogStash::LicenseChecker::LICENSE_TYPES
|
||||
|
||||
xpack_modules.each do |name|
|
||||
path = File.join(File.dirname(__FILE__), "..", "..", "modules", name, "configuration")
|
||||
|
|
|
@ -336,8 +336,8 @@ describe LogStash::ConfigManagement::ElasticsearchSource do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
%w(standard trial standard gold platinum).each do |license_type|
|
||||
# config management can be used with any license type except basic
|
||||
(::LogStash::LicenseChecker::LICENSE_TYPES - ["basic"]).each do |license_type|
|
||||
context "With a valid #{license_type} license, it should return a pipeline" do
|
||||
|
||||
before do
|
||||
|
@ -356,7 +356,6 @@ describe LogStash::ConfigManagement::ElasticsearchSource do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "with multiples `pipeline_id` configured" do
|
||||
|
|
|
@ -94,14 +94,14 @@ describe LogStash::LicenseChecker::XPackInfo do
|
|||
let(:status) { 'expired' }
|
||||
it_behaves_like 'available? returns correctly', true
|
||||
it_behaves_like 'active? returns correctly', false
|
||||
it_behaves_like 'one_of? returns correctly', %w(basic trial standard gold platinum), true
|
||||
it_behaves_like 'one_of? returns correctly', LogStash::LicenseChecker::LICENSE_TYPES, true
|
||||
end
|
||||
|
||||
context 'the license is active' do
|
||||
let(:status) { 'active' }
|
||||
it_behaves_like 'available? returns correctly', true
|
||||
it_behaves_like 'active? returns correctly', true
|
||||
it_behaves_like 'one_of? returns correctly', %w(basic trial standard gold platinum), true
|
||||
it_behaves_like 'one_of? returns correctly', LogStash::LicenseChecker::LICENSE_TYPES, true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ require 'license_checker/x_pack_info'
|
|||
|
||||
describe LogStash::LicenseChecker::ModuleLicenseChecker do
|
||||
|
||||
let(:license_types) { LogStash::LicenseChecker::LICENSE_TYPES }
|
||||
|
||||
let(:settings) { LogStash::Runner::SYSTEM_SETTINGS }
|
||||
|
||||
|
@ -55,7 +56,7 @@ describe LogStash::LicenseChecker::ModuleLicenseChecker do
|
|||
end
|
||||
|
||||
context "any license" do
|
||||
let(:subject) {LogStash::LicenseChecker::ModuleLicenseChecker.new(name, ["basic", "trial", "standard", "gold", "platinum"])}
|
||||
let(:subject) {LogStash::LicenseChecker::ModuleLicenseChecker.new(name, license_types)}
|
||||
let(:returned_license) {"basic"}
|
||||
let(:name) {"foo_module"}
|
||||
let(:settings) do
|
||||
|
@ -103,7 +104,7 @@ describe LogStash::LicenseChecker::ModuleLicenseChecker do
|
|||
end
|
||||
|
||||
context "no license" do
|
||||
let(:subject) {LogStash::LicenseChecker::ModuleLicenseChecker.new(name, ["basic", "trial", "standard", "gold", "platinum"])}
|
||||
let(:subject) {LogStash::LicenseChecker::ModuleLicenseChecker.new(name, license_types)}
|
||||
let(:name) {"foo_module"}
|
||||
let(:settings) do
|
||||
LogStash::SETTINGS.clone.tap do |settings|
|
||||
|
|
|
@ -101,7 +101,7 @@ describe LogStash::Monitoring::InternalPipelineSource do
|
|||
end
|
||||
end
|
||||
|
||||
%w(basic standard trial gold platinum).each do |license_type|
|
||||
LogStash::LicenseChecker::LICENSE_TYPES.each do |license_type|
|
||||
context "With a valid #{license_type} license" do
|
||||
let(:license_type) { license_type }
|
||||
let(:license) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue