mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
parent
3b55273262
commit
10e0ef9c7e
4 changed files with 7 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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] }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue