summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-08-08 19:37:34 +0000
committerDouwe Maan <douwe@gitlab.com>2016-08-08 19:37:34 +0000
commit37005ed8bd5c02be1b7734ebb295ab77f908011d (patch)
treeb5a3ffd91f1eb28bbcf9e7eea51b8e7ecd5b613d /app/services
parent86c081f71fabbc5877b415031855df2d83e9c64c (diff)
parent7e47a82899bdb10d2cdc61ce237a25bfa7f8a392 (diff)
downloadgitlab-ce-37005ed8bd5c02be1b7734ebb295ab77f908011d.tar.gz
Merge branch 'zj-enable-deploy-keys-api' into 'master'
Enable/Disable Deploy keys for a project Closes #20123 ## Does this MR meet the acceptance criteria? - [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [X] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [X] API support added - Tests - [X] Added for this feature/bug - [X] All builds are passing See merge request !5647
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/enable_deploy_key_service.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/projects/enable_deploy_key_service.rb b/app/services/projects/enable_deploy_key_service.rb
new file mode 100644
index 00000000000..3cf4264ce9b
--- /dev/null
+++ b/app/services/projects/enable_deploy_key_service.rb
@@ -0,0 +1,17 @@
+module Projects
+ class EnableDeployKeyService < BaseService
+ def execute
+ key = accessible_keys.find_by(id: params[:key_id] || params[:id])
+ return unless key
+
+ project.deploy_keys << key
+ key
+ end
+
+ private
+
+ def accessible_keys
+ current_user.accessible_deploy_keys
+ end
+ end
+end