summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-09 14:46:34 +0200
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-16 10:52:28 +0200
commit846f73b53b8a6d3bc1f18607630d7a7853cb9d13 (patch)
treedf9839140353d8bdfff777ccb71eaad1b1f4e8df /app/models
parent4790e726d31562b68fec283173e9885df8a5cdda (diff)
downloadgitlab-ce-846f73b53b8a6d3bc1f18607630d7a7853cb9d13.tar.gz
Allow group runners to be viewed/edited in API
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/runner.rb2
-rw-r--r--app/models/user.rb16
2 files changed, 15 insertions, 3 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index bda69f85a78..e6f1ed519be 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -52,7 +52,7 @@ module Ci
# Without that, placeholders would miss one and couldn't match.
where(locked: false)
.where.not("ci_runners.id IN (#{project.runners.select(:id).to_sql})")
- .specific
+ .project_type
end
validate :tag_constraints
diff --git a/app/models/user.rb b/app/models/user.rb
index 173ab38e20c..2afe9ea77f9 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1001,10 +1001,17 @@ class User < ActiveRecord::Base
def ci_authorized_runners
@ci_authorized_runners ||= begin
- runner_ids = Ci::RunnerProject
+ project_runner_ids = Ci::RunnerProject
.where(project: authorized_projects(Gitlab::Access::MASTER))
.select(:runner_id)
- Ci::Runner.specific.where(id: runner_ids)
+
+ group_runner_ids = Ci::RunnerNamespace
+ .where(namespace_id: owned_or_masters_groups.select(:id))
+ .select(:runner_id)
+
+ union = Gitlab::SQL::Union.new([project_runner_ids, group_runner_ids])
+
+ Ci::Runner.specific.where("ci_runners.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection
end
end
@@ -1205,6 +1212,11 @@ class User < ActiveRecord::Base
!terms_accepted?
end
+ def owned_or_masters_groups
+ union = Gitlab::SQL::Union.new([owned_groups, masters_groups])
+ Group.from("(#{union.to_sql}) namespaces")
+ end
+
protected
# override, from Devise::Validatable