correct ES_client to only split strings + add csv_string(array) method (#7722)

an x-pack-logstash PR will be reliant on the csv_string method.
This commit is contained in:
Guy Boertje 2017-07-18 15:40:49 +01:00 committed by GitHub
parent e87f810c76
commit dbcce19888
2 changed files with 9 additions and 1 deletions

View file

@ -108,7 +108,11 @@ module LogStash class ElasticsearchClient
end
def unpack_hosts
@settings.fetch("var.elasticsearch.hosts", "localhost:9200").split(',').map(&:strip)
setting = @settings.fetch("var.elasticsearch.hosts", "localhost:9200")
if setting.is_a?(String)
return setting.split(',').map(&:strip)
end
setting
end
end

View file

@ -33,6 +33,10 @@ module LogStash module Modules class LogStashConfig
"[#{array.collect { |i| "'#{i}'" }.join(", ")}]"
end
def csv_string(array)
"'#{array.join(',')}'"
end
def get_setting(setting_class)
raw_value = @settings[setting_class.name]
# If we dont check for NIL, the Settings class will try to coerce the value