summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 18:26:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 18:26:46 +0000
commit5509e479900ee537980a126287c20327c41a61d6 (patch)
tree8272f06bd58b1518eca38975f95656ffc5497bd2 /app/services
parente0529f76a36026dc4bd51fbec1e5c52e7f3866e1 (diff)
downloadgitlab-ce-5509e479900ee537980a126287c20327c41a61d6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/runners/unregister_runner_manager_service.rb33
-rw-r--r--app/services/ci/runners/unregister_runner_service.rb3
2 files changed, 35 insertions, 1 deletions
diff --git a/app/services/ci/runners/unregister_runner_manager_service.rb b/app/services/ci/runners/unregister_runner_manager_service.rb
new file mode 100644
index 00000000000..ecf6aba09c7
--- /dev/null
+++ b/app/services/ci/runners/unregister_runner_manager_service.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Ci
+ module Runners
+ class UnregisterRunnerManagerService
+ attr_reader :runner, :author, :system_id
+
+ # @param [Ci::Runner] runner the runner to unregister/destroy
+ # @param [User, authentication token String] author the user or the authentication token authorizing the removal
+ # @param [String] system_id ID of the system being unregistered
+ def initialize(runner, author, system_id:)
+ @runner = runner
+ @author = author
+ @system_id = system_id
+ end
+
+ def execute
+ return system_id_missing_error if system_id.blank?
+
+ runner_manager = runner.runner_managers.find_by_system_xid!(system_id)
+ runner_manager.destroy!
+
+ ServiceResponse.success
+ end
+
+ private
+
+ def system_id_missing_error
+ ServiceResponse.error(message: '`system_id` needs to be specified for runners created in the UI.')
+ end
+ end
+ end
+end
diff --git a/app/services/ci/runners/unregister_runner_service.rb b/app/services/ci/runners/unregister_runner_service.rb
index 742b21f77df..d186bd421d5 100644
--- a/app/services/ci/runners/unregister_runner_service.rb
+++ b/app/services/ci/runners/unregister_runner_service.rb
@@ -13,7 +13,8 @@ module Ci
end
def execute
- @runner&.destroy
+ runner.destroy!
+
ServiceResponse.success
end
end