Sha256: c4f63da2f8d6dadc5d960e2a2a155db51f2510720634b9b1acb83fc80292deab

Contents?: true

Size: 1.48 KB

Versions: 35

Compression:

Stored size: 1.48 KB

Contents

class Fluentd::Settings::InTailController < ApplicationController
  before_action :login_required
  before_action :find_fluentd

  def after_file_choose
    @setting = Fluentd::Setting::InTail.new({
      :path => params[:path],
      :tag => nil,
    })
  end

  def after_format
    # NOTE: pos_file form field doesn't exists before this action
    attrs = setting_params
    if attrs[:pos_file].blank?
      attrs.merge!(pos_file: "/tmp/fluentd-#{@fluentd.id}-#{Time.now.to_i}.pos")
    end
    @setting = Fluentd::Setting::InTail.new(attrs)
  end

  def confirm
    @setting = Fluentd::Setting::InTail.new(setting_params)
    if params[:back]
      return render :after_file_choose
    end
    unless @setting.valid?
      return render :after_format
    end
  end

  def finish
    @setting = Fluentd::Setting::InTail.new(setting_params)
    if params[:back]
      return render :after_format
    end

    unless @setting.valid?
      return render "after_format"
    end

    if @fluentd.agent.configuration.to_s.include?(@setting.to_conf.strip)
      @setting.errors.add(:base, :duplicated_conf)
      return render "after_format"
    end

    @fluentd.agent.config_append @setting.to_conf
    @fluentd.agent.restart if @fluentd.agent.running?
    redirect_to daemon_setting_path(@fluentd)
  end

  private

  def setting_params
    params.require(:setting).permit(:path, :format, :regexp, *Fluentd::Setting::InTail.known_formats, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval)
  end

end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
fluentd-ui-1.0.0.alpha.2 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-1.0.0.alpha.1 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.5 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.4 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.3 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.2 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.1 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.4.0 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.21 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.20 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.19 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.18 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.17 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.16 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.15 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.14 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.13 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.12 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.11 app/controllers/fluentd/settings/in_tail_controller.rb
fluentd-ui-0.3.10 app/controllers/fluentd/settings/in_tail_controller.rb