summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-05-04 09:44:05 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-05-04 09:44:05 +0000
commit04d07cc5b4177132d3dcf0afb1729314a4b284cb (patch)
tree4fd3fb55a40f7d5253b1106edecc52821a2928c7 /lib/api
parentbee5e26e2d84ce514f2fbedd05bd6e70271142b2 (diff)
parent11f38dd12abedf17c09098170de295ce0b533d3b (diff)
downloadgitlab-ce-04d07cc5b4177132d3dcf0afb1729314a4b284cb.tar.gz
Merge branch 'feature/runner-per-group' into 'master'
Shared CI runners for groups See merge request gitlab-org/gitlab-ce!9646
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb18
-rw-r--r--lib/api/runner.rb9
2 files changed, 21 insertions, 6 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 1619c1a09ee..086071161b7 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -242,13 +242,18 @@ module API
expose :requested_at
end
- class Group < Grape::Entity
- expose :id, :name, :path, :description, :visibility
+ class BasicGroupDetails < Grape::Entity
+ expose :id
+ expose :web_url
+ expose :name
+ end
+
+ class Group < BasicGroupDetails
+ expose :path, :description, :visibility
expose :lfs_enabled?, as: :lfs_enabled
expose :avatar_url do |group, options|
group.avatar_url(only_path: false)
end
- expose :web_url
expose :request_access_enabled
expose :full_name, :full_path
@@ -984,6 +989,13 @@ module API
options[:current_user].authorized_projects.where(id: runner.projects)
end
end
+ expose :groups, with: Entities::BasicGroupDetails do |runner, options|
+ if options[:current_user].admin?
+ runner.groups
+ else
+ options[:current_user].authorized_groups.where(id: runner.groups)
+ end
+ end
end
class RunnerRegistrationDetails < Grape::Entity
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 4d4fbe50f9f..67896ae1fc5 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -23,10 +23,13 @@ module API
runner =
if runner_registration_token_valid?
# Create shared runner. Requires admin access
- Ci::Runner.create(attributes.merge(is_shared: true))
+ Ci::Runner.create(attributes.merge(is_shared: true, runner_type: :instance_type))
elsif project = Project.find_by(runners_token: params[:token])
- # Create a specific runner for project.
- project.runners.create(attributes)
+ # Create a specific runner for the project
+ project.runners.create(attributes.merge(runner_type: :project_type))
+ elsif group = Group.find_by(runners_token: params[:token])
+ # Create a specific runner for the group
+ group.runners.create(attributes.merge(runner_type: :group_type))
end
break forbidden! unless runner