2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-08 18:32:10 +00:00
|
|
|
module Projects
|
|
|
|
class EnableDeployKeyService < BaseService
|
|
|
|
def execute
|
|
|
|
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
|
|
|
|
return unless key
|
|
|
|
|
2017-05-01 05:22:11 +00:00
|
|
|
unless project.deploy_keys.include?(key)
|
|
|
|
project.deploy_keys << key
|
|
|
|
end
|
|
|
|
|
2016-08-08 18:32:10 +00:00
|
|
|
key
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def accessible_keys
|
|
|
|
current_user.accessible_deploy_keys
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|