From 605c3c6358002452914876ced51ab4ef85cc7615 Mon Sep 17 00:00:00 2001 From: Ben Abrams Date: Mon, 24 Jan 2022 02:22:23 -0800 Subject: [PATCH] allow the ability to cleanup previously configured local sources In some cases even if temporarily one may want to remove a source from being ingested into sumologic. In other cases it's cleaning up dead code for something that no longer generates logs in the environment. Signed-off-by: Ben Abrams --- README.md | 1 + libraries/provider_source.rb | 6 ++++++ libraries/resource_source.rb | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 01b3358..958ac68 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,7 @@ sumo_source_local_file `default` = `:create` - `:create` - creates a JSON Source configuration +- `:remove` - removes a previously configured JSON source configuration ### Attribute Parameters diff --git a/libraries/provider_source.rb b/libraries/provider_source.rb index 677768f..c92f359 100644 --- a/libraries/provider_source.rb +++ b/libraries/provider_source.rb @@ -35,6 +35,12 @@ def load_current_resource end end + action :remove do + file source_json_path do + action :delete + end + end + def api_version 'v1' end diff --git a/libraries/resource_source.rb b/libraries/resource_source.rb index 9015698..5551f5d 100644 --- a/libraries/resource_source.rb +++ b/libraries/resource_source.rb @@ -10,7 +10,7 @@ class SumoSource < Chef::Resource::LWRPBase default_action :create - actions :create + actions :create, :remove attribute :owner, regex: Chef::Config[:user_valid_regex] attribute :group, regex: Chef::Config[:group_valid_regex]