Class: FluentPluginConfigFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/command/plugin_config_formatter.rb

Constant Summary collapse

AVAILABLE_FORMATS =
[:markdown, :txt, :json]
SUPPORTED_TYPES =
[
  "input", "output", "filter",
  "buffer", "parser", "formatter", "storage",
  "service_discovery"
]
DOCS_BASE_URL =
"https://docs.fluentd.org/v/1.0"
DOCS_PLUGIN_HELPER_BASE_URL =
"#{DOCS_BASE_URL}/plugin-helper-overview/"

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ FluentPluginConfigFormatter

Returns a new instance of FluentPluginConfigFormatter.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fluent/command/plugin_config_formatter.rb', line 39

def initialize(argv = ARGV)
  @argv = argv

  @compact = false
  @format = :markdown
  @verbose = false
  @libs = []
  @plugin_dirs = []
  @table = false
  @options = {}

  prepare_option_parser
end

Instance Method Details

#callObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fluent/command/plugin_config_formatter.rb', line 53

def call
  parse_options!
  init_libraries
  @plugin = Fluent::Plugin.__send__("new_#{@plugin_type}", @plugin_name)
  dumped_config = {}
  if @plugin.class.respond_to?(:plugin_helpers)
    dumped_config[:plugin_helpers] = @plugin.class.plugin_helpers
  end
  @plugin.class.ancestors.reverse_each do |plugin_class|
    next unless plugin_class.respond_to?(:dump_config_definition)
    unless @verbose
      next if /::PluginHelper::/.match?(plugin_class.name)
    end
    dumped_config_definition = plugin_class.dump_config_definition
    dumped_config[plugin_class.name] = dumped_config_definition unless dumped_config_definition.empty?
  end
  case @format
  when :txt
    puts dump_txt(dumped_config)
  when :markdown
    puts dump_markdown(dumped_config)
  when :json
    puts dump_json(dumped_config)
  end
end