Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/gitlab/web_hook.rake')
-rw-r--r--lib/tasks/gitlab/web_hook.rake11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/tasks/gitlab/web_hook.rake b/lib/tasks/gitlab/web_hook.rake
index fc17c7d0177..9aa0f07de5f 100644
--- a/lib/tasks/gitlab/web_hook.rake
+++ b/lib/tasks/gitlab/web_hook.rake
@@ -22,11 +22,13 @@ namespace :gitlab do
end
end
- desc "GitLab | Webhook | Remove a webhook from the projects"
- task rm: :environment do
+ desc "GitLab | Webhook | Remove a webhook from a namespace"
+ task rm: :environment do |task|
web_hook_url = ENV['URL']
namespace_path = ENV['NAMESPACE']
+ raise ArgumentError, 'URL is required' unless web_hook_url
+
web_hooks = find_web_hooks(namespace_path)
puts "Removing webhooks with the url '#{web_hook_url}' ... "
@@ -36,11 +38,12 @@ namespace :gitlab do
# we could consider storing a hash of the URL alongside the encrypted
# value to speed up searches
count = 0
+ service = WebHooks::AdminDestroyService.new(rake_task: task)
+
web_hooks.find_each do |hook|
next unless hook.url == web_hook_url
- user = hook.parent.owners.first
- result = WebHooks::DestroyService.new(user).execute(hook)
+ result = service.execute(hook)
raise "Unable to destroy Web hook" unless result[:status] == :success