move Pipeline#validate_config to Runner

Fixes #4946
This commit is contained in:
Joao Duarte 2016-03-31 15:22:22 +01:00 committed by João Duarte
parent 3b55273262
commit 10e0ef9c7e
4 changed files with 7 additions and 15 deletions

View file

@ -52,16 +52,6 @@ module LogStash; class Pipeline
"LogStash::Inputs::Stdin"
]
def self.validate_config(config_str, settings = {})
begin
# There should be a better way to test this
self.new(config_str, settings)
true
rescue => e
e.message
end
end
def initialize(config_str, settings = {})
@config_str = config_str
@original_settings = settings

View file

@ -168,12 +168,12 @@ class LogStash::Runner < Clamp::Command
if config_test?
config_loader = LogStash::Config::Loader.new(@logger)
config_str = config_loader.format_config(config_path, config_string)
config_error = LogStash::Pipeline.validate_config(config_str)
if config_error == true
begin
LogStash::Pipeline.new(config_str)
@logger.terminal "Configuration OK"
return 0
else
@logger.fatal I18n.t("logstash.error", :error => config_error)
rescue => e
@logger.fatal I18n.t("logstash.runner.invalid-configuration", :error => e.message)
return 1
end
end

View file

@ -91,6 +91,8 @@ en:
bin/logstash -i SHELL [--quiet|verbose|debug]
bin/logstash -V [--verbose|debug]
bin/logstash --help
invalid-configuration: >-
The given configuration is invalid. Reason: %{error}
missing-configuration: >-
No configuration file was specified. Perhaps you forgot to provide
the '-f yourlogstash.conf' flag?

View file

@ -95,7 +95,7 @@ describe LogStash::Runner do
end
end
context "--config-test" do
describe "--config-test" do
subject { LogStash::Runner.new("") }
let(:args) { ["-t", "-e", pipeline_string] }