Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsl: Need '@' prefix for reserved system parameters. fix #2028 #2034

Merged
merged 5 commits into from
Jun 26, 2018
Merged
Changes from 1 commit
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: 8 additions & 5 deletions lib/fluent/config/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
module Fluent
module Config
module DSL
SYSTEM_PARAM = [:type, :id, :log_level] # Add '@' prefix to avoid deprecation message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@cosmo0920 cosmo0920 Jun 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to handle label, too?

diff --git a/lib/fluent/config/dsl.rb b/lib/fluent/config/dsl.rb
index c315a3f1..c8a0bb78 100644
--- a/lib/fluent/config/dsl.rb
+++ b/lib/fluent/config/dsl.rb
@@ -22,7 +22,7 @@ require 'fluent/config/element'
 module Fluent
   module Config
     module DSL
-      SYSTEM_PARAM = [:type, :id, :log_level] # Add '@' prefix to avoid depreca
tion message
+      SYSTEM_PARAM = [:type, :id, :log_level, :label] # Add '@' prefix to avoid
 deprecation message
 
       module Parser
         def self.read(path)

can handle label parameter with the following configuration:

source {
  type :forward
  label :"@forward"
}

label('@forward') {
  filter('**') {
    type :stdout
  }

  match('**') {
    type :null
  }
}


module Parser
def self.read(path)
path = File.expand_path(path)
Expand Down Expand Up @@ -95,11 +97,12 @@ def method_missing(name, *args, &block)
proxy.element.instance_exec(&block)
@elements.push(proxy.to_config_element)
else
@attrs[name.to_s] = if value.is_a?(Array) || value.is_a?(Hash)
JSON.dump(value)
else
value.to_s
end
param_name = SYSTEM_PARAM.include?(name) ? "@#{name}" : name.to_s
@attrs[param_name] = if value.is_a?(Array) || value.is_a?(Hash)
JSON.dump(value)
else
value.to_s
end
end

self
Expand Down