diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-19 03:12:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-19 03:12:52 +0000 |
commit | ad7d53a71ad82f0d44b9b95aa7d0ba7bfaa1d6b6 (patch) | |
tree | 185aa45a7450e889311be78723a2e1fe2d8a8aef /app/services | |
parent | f764c2fd9e05c90155ade99e3247556cce0c7412 (diff) | |
download | gitlab-ce-ad7d53a71ad82f0d44b9b95aa7d0ba7bfaa1d6b6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/runners/set_runner_associated_projects_service.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/services/ci/runners/set_runner_associated_projects_service.rb b/app/services/ci/runners/set_runner_associated_projects_service.rb index 759bd2ffb16..7930776749d 100644 --- a/app/services/ci/runners/set_runner_associated_projects_service.rb +++ b/app/services/ci/runners/set_runner_associated_projects_service.rb @@ -17,6 +17,8 @@ module Ci return ServiceResponse.error(message: 'user not allowed to assign runner', http_status: :forbidden) end + return ServiceResponse.success if project_ids.blank? + set_associated_projects end @@ -47,16 +49,15 @@ module Ci def associate_new_projects(new_project_ids, current_project_ids) missing_projects = Project.id_in(new_project_ids - current_project_ids) - missing_projects.each do |project| - return false unless runner.assign_to(project, current_user) - end - - true + missing_projects.all? { |project| runner.assign_to(project, current_user) } end def disassociate_old_projects(new_project_ids, current_project_ids) + projects_to_be_deleted = current_project_ids - new_project_ids + return true if projects_to_be_deleted.empty? + Ci::RunnerProject - .destroy_by(project_id: current_project_ids - new_project_ids) + .destroy_by(project_id: projects_to_be_deleted) .all?(&:destroyed?) end |