mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-08 04:16:11 +02:00
Add <secondary> for out_forward
This commit is contained in:
parent
0286c39c89
commit
b36b3eb483
@ -4,6 +4,11 @@ class Fluentd::Settings::OutForwardController < ApplicationController
|
||||
|
||||
def show
|
||||
@setting = Fluentd::Setting::OutForward.new({
|
||||
secondary: {
|
||||
"0" => {
|
||||
type: "file",
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@ -27,7 +32,10 @@ class Fluentd::Settings::OutForwardController < ApplicationController
|
||||
|
||||
def setting_params
|
||||
params.require(:fluentd_setting_out_forward).permit(*Fluentd::Setting::OutForward::KEYS).merge(
|
||||
params.require(:fluentd_setting_out_forward).permit(:server => Fluentd::Setting::OutForward::Server::KEYS)
|
||||
params.require(:fluentd_setting_out_forward).permit(
|
||||
:server => Fluentd::Setting::OutForward::Server::KEYS,
|
||||
:secondary => Fluentd::Setting::OutForward::Secondary::KEYS,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ module SettingsHelper
|
||||
html = '<div class="form-group">'
|
||||
|
||||
case form.object.column_type(key)
|
||||
when :hidden
|
||||
return form.hidden_field(key)
|
||||
when :boolean, :flag
|
||||
html << form.check_box(key, {}, "true", "false")
|
||||
html << " " # NOTE: Adding space for padding
|
||||
|
||||
@ -5,7 +5,7 @@ class Fluentd
|
||||
include ActiveModel::Model
|
||||
|
||||
module ClassMethods
|
||||
attr_accessor :values, :types, :children
|
||||
attr_accessor :values, :types, :children, :hidden_values
|
||||
|
||||
def choice(key, values)
|
||||
@values ||= {}
|
||||
@ -13,6 +13,10 @@ class Fluentd
|
||||
set_type(:choice, [key])
|
||||
end
|
||||
|
||||
def hidden(key)
|
||||
set_type(:hidden, [key])
|
||||
end
|
||||
|
||||
def nested(key, klass, options = {})
|
||||
# e.g.:
|
||||
# <match>
|
||||
@ -92,7 +96,7 @@ class Fluentd
|
||||
"\n" + child_instance.to_config(key).gsub(/^/m, " ")
|
||||
end
|
||||
end.join
|
||||
else
|
||||
else # including :hidden
|
||||
print_if_present(key)
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,18 +14,31 @@ class Fluentd
|
||||
validates :host, presence: true
|
||||
end
|
||||
|
||||
class Secondary
|
||||
include Common
|
||||
KEYS = [
|
||||
:path, :type
|
||||
].freeze
|
||||
|
||||
attr_accessor(*KEYS)
|
||||
|
||||
hidden :type
|
||||
validates :path, presence: true
|
||||
end
|
||||
|
||||
include Common
|
||||
|
||||
KEYS = [
|
||||
:match,
|
||||
:send_timeout, :recover_wait, :heartbeat_type, :heartbeat_interval,
|
||||
:phi_threshold, :hard_timeout,
|
||||
:server
|
||||
:server, :secondary
|
||||
].freeze
|
||||
|
||||
attr_accessor(*KEYS)
|
||||
choice :heartbeat_type, %w(udp tcp)
|
||||
nested :server, Server
|
||||
nested :secondary, Secondary
|
||||
|
||||
validates :match, presence: true
|
||||
validate :validate_at_least_one_server
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
= form_for(@setting, url: finish_fluentd_setting_out_forward_path(@fluentd), html: {class: "ignore-rails-error-div"}) do |f|
|
||||
= field(f, :match)
|
||||
= field(f, :server)
|
||||
= field(f, :secondary)
|
||||
|
||||
.well.well-sm
|
||||
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
|
||||
|
||||
@ -32,6 +32,18 @@ describe Fluentd::Setting::Common do
|
||||
it { subject.column_type(:foo).should_not == :flag }
|
||||
end
|
||||
|
||||
describe "#hidden" do
|
||||
subject do
|
||||
Class.new do
|
||||
include Fluentd::Setting::Common
|
||||
attr_accessor :hide
|
||||
hidden :hide
|
||||
end.new
|
||||
end
|
||||
|
||||
it { subject.column_type(:hide).should == :hidden }
|
||||
end
|
||||
|
||||
describe "#choice" do
|
||||
subject do
|
||||
Class.new do
|
||||
@ -109,10 +121,11 @@ describe Fluentd::Setting::Common do
|
||||
end
|
||||
@klass = Class.new do
|
||||
include Fluentd::Setting::Common
|
||||
KEYS = [:key1, :key2, :flag1, :ch, :child, :string] # FIXME: display "warning: already initialized constant KEYS", but works :(
|
||||
KEYS = [:key1, :key2, :flag1, :hide, :ch, :child, :string] # FIXME: display "warning: already initialized constant KEYS", but works :(
|
||||
attr_accessor(*KEYS)
|
||||
booleans :key1, :key2
|
||||
flags :flag1
|
||||
hidden :hide
|
||||
choice :ch, %w(foo bar)
|
||||
nested :child, Child
|
||||
end
|
||||
@ -140,6 +153,11 @@ describe Fluentd::Setting::Common do
|
||||
end
|
||||
end
|
||||
|
||||
describe "hidden" do
|
||||
let(:params) { {hide: "foo"} }
|
||||
it { should include("hide foo\n") }
|
||||
end
|
||||
|
||||
describe "choice" do
|
||||
let(:params) { {ch: "foo"} }
|
||||
it { should include("ch foo\n") }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user