From a13c488d0e3e36771fa4f3cdb0b19e44981e8d99 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Fri, 14 Sep 2018 12:40:48 +0900 Subject: [PATCH] Use Fluentd::Setting::Config#delete_element Signed-off-by: Kenji Okimoto --- app/controllers/api/settings_controller.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/settings_controller.rb b/app/controllers/api/settings_controller.rb index 0fcdf81..a681c76 100644 --- a/app/controllers/api/settings_controller.rb +++ b/app/controllers/api/settings_controller.rb @@ -25,13 +25,19 @@ class Api::SettingsController < ApplicationController end def destroy - unless @config.elements.index(@section) - render_404 - return + if params[:label] == "ROOT" + name = params[:pluginType] + arg = params[:arg] + else + name = "label" + arg = params[:label] + end + if @config.delete_element(name, arg, @target_element) + @config.write_to_file + head :no_content # 204 + else + render_404 end - @config.elements.delete @section - @config.write_to_file - head :no_content # 204 end private