diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /lib/tasks/gitlab/web_hook.rake | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/web_hook.rake')
-rw-r--r-- | lib/tasks/gitlab/web_hook.rake | 11 |
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 |