Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/autocomplete/deploy_keys_with_write_access_finder.rb')
-rw-r--r--app/finders/autocomplete/deploy_keys_with_write_access_finder.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb b/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb
new file mode 100644
index 00000000000..a123a0dc4f0
--- /dev/null
+++ b/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Autocomplete
+ # Finder for retrieving deploy keys to use for autocomplete data sources.
+ class DeployKeysWithWriteAccessFinder
+ attr_reader :current_user, :project
+
+ def initialize(current_user, project)
+ @current_user = current_user
+ @project = project
+ end
+
+ def execute
+ return DeployKey.none if project.nil?
+
+ raise Gitlab::Access::AccessDeniedError unless current_user.can?(:admin_project, project)
+
+ project.deploy_keys.merge(DeployKeysProject.with_write_access)
+ end
+ end
+end