mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 19:06:12 +02:00
Support storage section
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
9cbc616624
commit
b14da4174f
@ -11,6 +11,7 @@ module SettingConcern
|
||||
def show
|
||||
@setting = target_class.new(initial_params)
|
||||
@buffer = @setting.create_buffer
|
||||
@storage = @setting.create_storage
|
||||
@parser = @setting.create_parser
|
||||
@formatter = @setting.create_formatter
|
||||
@_used_param = {}
|
||||
@ -22,6 +23,7 @@ module SettingConcern
|
||||
owned_keys = %i(parse_type format_type)
|
||||
@setting = target_class.new(initial_params.merge(params.permit(*owned_keys).slice(*owned_keys)))
|
||||
@buffer = @setting.create_buffer
|
||||
@storage = @setting.create_storage
|
||||
@parser = @setting.create_parser
|
||||
@formatter = @setting.create_formatter
|
||||
render "shared/settings/show"
|
||||
|
||||
@ -33,6 +33,10 @@ class Fluentd
|
||||
self.class._sections.key?(:buffer)
|
||||
end
|
||||
|
||||
def have_storage_section?
|
||||
self.class._sections.key?(:storage)
|
||||
end
|
||||
|
||||
def have_parse_section?
|
||||
self.class._sections.key?(:parse)
|
||||
end
|
||||
@ -47,6 +51,12 @@ class Fluentd
|
||||
buffer_class.new(buffer["0"].except("type"))
|
||||
end
|
||||
|
||||
def create_storage
|
||||
return unless have_storage_section?
|
||||
storage_class = Fluentd::Setting.const_get("storage_#{storage_type}".classify)
|
||||
storage_class.new(storage["0"].except("type"))
|
||||
end
|
||||
|
||||
def create_parser
|
||||
return unless have_parse_section?
|
||||
parser_class = Fluentd::Setting.const_get("parser_#{parse_type}".classify)
|
||||
|
||||
22
app/models/fluentd/setting/storage_local.rb
Normal file
22
app/models/fluentd/setting/storage_local.rb
Normal file
@ -0,0 +1,22 @@
|
||||
class Fluentd
|
||||
module Setting
|
||||
class StorageLocal
|
||||
include Fluentd::Setting::Plugin
|
||||
|
||||
register_plugin("storage", "local")
|
||||
|
||||
def self.initial_params
|
||||
{}
|
||||
end
|
||||
|
||||
def common_options
|
||||
[
|
||||
:path,
|
||||
:mode,
|
||||
:dir_mode,
|
||||
:pretty_print
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -8,6 +8,9 @@
|
||||
- if @setting.have_buffer_section?
|
||||
= render "shared/settings/buffer_form", form: form, buffer: @buffer
|
||||
|
||||
- if @setting.have_storage_section?
|
||||
= render "shared/settings/storage_form", form: form, storage: @storage
|
||||
|
||||
- if @setting.have_parse_section?
|
||||
= render "shared/settings/parser_form", form: form, parser: @parser
|
||||
|
||||
|
||||
7
app/views/shared/settings/_storage_form.html.haml
Normal file
7
app/views/shared/settings/_storage_form.html.haml
Normal file
@ -0,0 +1,7 @@
|
||||
#storage-section.form-group.card.bg-light.mb-3
|
||||
.card-body
|
||||
= form.label(:storage_type, "Storage")
|
||||
= form.select(:storage_type, Fluent::Plugin::STORAGE_REGISTRY.map.keys, {}, { class: "storage form-control" })
|
||||
= form.fields("storage[0]", model: storage, class: ".form-group", builder: FluentdFormBuilder) do |storage_form|
|
||||
- storage_form.object.common_options.each do |key|
|
||||
= storage_form.field(key)
|
||||
Loading…
x
Reference in New Issue
Block a user