Skip to content

Commit

Permalink
fluentd: Suppress unread configuration warning (#1242)
Browse files Browse the repository at this point in the history
* suppress unread configuration warning

* make client certificate optional
  • Loading branch information
tarokkk authored and cyriltovena committed Nov 11, 2019
1 parent 9231169 commit 3787596
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)

Gem::Specification.new do |spec|
spec.name = 'fluent-plugin-grafana-loki'
spec.version = '1.2.1'
spec.version = '1.2.2'
spec.authors = %w[woodsaj briangann]
spec.email = ['[email protected]', '[email protected]']

Expand Down
12 changes: 7 additions & 5 deletions fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def configure(conf)
@record_accessors = {}
conf.elements.select { |element| element.name == 'label' }.each do |element|
element.each_pair do |k, v|
element.key?(k) # to suppress unread configuration warning
element.has_key?(k) # rubocop:disable Style/PreferredHashMethods #to suppress unread configuration warning
v = k if v.empty?
@record_accessors[k] = record_accessor_create(v)
end
Expand All @@ -86,11 +86,13 @@ def configure(conf)
@remove_keys_accessors.push(record_accessor_create(key))
end

@cert = OpenSSL::X509::Certificate.new(File.read(@cert)) if @cert
@key = OpenSSL::PKey.read(File.read(key)) if @key
if !@key.nil? && !@cert.nil?
@cert = OpenSSL::X509::Certificate.new(File.read(@cert)) if @cert
@key = OpenSSL::PKey.read(File.read(@key)) if @key

if !@key.is_a?(OpenSSL::PKey::RSA) && !@key.is_a?(OpenSSL::PKey::DSA)
raise "Unsupported private key type #{key.class}"
if !@key.is_a?(OpenSSL::PKey::RSA) && !@key.is_a?(OpenSSL::PKey::DSA)
raise "Unsupported private key type #{key.class}"
end
end

if !@ca_cert.nil? && !File.exist?(@ca_cert)
Expand Down

0 comments on commit 3787596

Please sign in to comment.