Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/fluent/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module FluentConfig
BUILTIN_PARAMETERS = ['type', 'id', 'label', 'log_level'].freeze
BUILTIN_PARAMETER_PREFIX = '@'.freeze
PREFIX_EXCEPTION_SCOPES = ['system', 'metric'].freeze
TAG_PATTERN = 'tag_pattern'.freeze
BODY_PADDING = ' '.freeze

Expand All @@ -23,7 +24,7 @@ def generate(config, header = '')
result << directive_tag(plugin_type, tag_pattern) do
plugin_config.keys.sort.reduce('') do |body, parameter|
body << directive_body(
(plugin_type == 'system' ? parameter : format_parameter(parameter)),
format_parameter(parameter, plugin_type),
plugin_config.fetch(parameter),
)
end
Expand Down Expand Up @@ -62,12 +63,10 @@ def left_pad(text, padding)
end
end

def format_parameter(parameter)
if BUILTIN_PARAMETERS.include?(parameter)
BUILTIN_PARAMETER_PREFIX + parameter
else
parameter
end
def format_parameter(parameter, scope)
return parameter if PREFIX_EXCEPTION_SCOPES.include? scope
return parameter unless BUILTIN_PARAMETERS.include? parameter
BUILTIN_PARAMETER_PREFIX + parameter
end
end
end