diff options
| author | Shinya Maeda <shinya@gitlab.com> | 2018-05-07 11:59:43 +0900 |
|---|---|---|
| committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-07 11:59:43 +0900 |
| commit | 1f39fcd1123c1a65798a0a0b3e5f3b2fa43651ac (patch) | |
| tree | 8d8a6a5a6a424c3f61332e509b97ab85cf0167b5 /lib/api | |
| parent | c1d3b48c96ce44a2ff3e84cb89063a00c67297f5 (diff) | |
| parent | 58aa2d7f395be4aee38b5202ef1666879505c737 (diff) | |
| download | gitlab-ce-1f39fcd1123c1a65798a0a0b3e5f3b2fa43651ac.tar.gz | |
Merge branch 'master' into live-trace-v2
Diffstat (limited to 'lib/api')
| -rw-r--r-- | lib/api/entities.rb | 19 | ||||
| -rw-r--r-- | lib/api/runner.rb | 9 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 1619c1a09ee..a9bab5c56cf 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -136,6 +136,7 @@ module API def self.preload_relation(projects_relation, options = {}) projects_relation.preload(:project_feature, :route) + .preload(:import_state) .preload(namespace: [:route, :owner], tags: :taggings) end @@ -242,13 +243,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 +990,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 |
