Separate fat action

This commit is contained in:
uu59 2015-02-04 16:13:48 +09:00
parent e0f0ccdc3b
commit 8dc2be80ef

View File

@ -18,22 +18,9 @@ class Fluentd::SettingsController < ApplicationController
def update
if params[:dryrun]
if dryrun(params[:config])
flash.now[:success] = I18n.t('messages.dryrun_is_passed')
else
flash.now[:danger] = @fluentd.agent.last_error_message
end
@config = params[:config]
render "edit"
handle_dryrun
else
begin
update_config(params[:config])
redirect_to daemon_setting_path(@fluentd)
rescue Fluent::ConfigParseError => e
@config = params[:config]
flash.now[:danger] = e.message
render "edit"
end
handle_update
end
end
@ -48,6 +35,25 @@ class Fluentd::SettingsController < ApplicationController
@config = @fluentd.agent.config
end
def handle_dryrun
if dryrun(params[:config])
flash.now[:success] = I18n.t('messages.dryrun_is_passed')
else
flash.now[:danger] = @fluentd.agent.last_error_message
end
@config = params[:config]
render "edit"
end
def handle_update
update_config(params[:config])
redirect_to daemon_setting_path(@fluentd)
rescue Fluent::ConfigParseError => e
@config = params[:config]
flash.now[:danger] = e.message
render "edit"
end
def dryrun(conf)
tmpfile = Tempfile.open("fluentd-test-config")
tmpfile.write params[:config]