diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-04 10:39:28 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-04 10:39:28 +0000 |
commit | 48bbb36347c1c5d4d7922e1998c47d235eb71208 (patch) | |
tree | d24a0587b1fed960aa5c8060d32aab1b8028b124 /lib/api | |
parent | d026441b3c68e682a136d09d68b18fa0a73684fe (diff) | |
parent | d3bcb06dc6365129b62dadf49efc58daecd39a83 (diff) | |
download | gitlab-ce-48bbb36347c1c5d4d7922e1998c47d235eb71208.tar.gz |
Merge branch 'remove-is-shared-from-ci-runners' into 'master'
Remove the use of `is_shared` of `Ci::Runner`
See merge request gitlab-org/gitlab-ce!20172
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/runner.rb | 6 | ||||
-rw-r--r-- | lib/api/runners.rb | 9 |
3 files changed, 12 insertions, 7 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index bb48a86fe9e..d04f92885a3 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1010,7 +1010,7 @@ module API expose :description expose :ip_address expose :active - expose :is_shared + expose :instance_type?, as: :is_shared expose :name expose :online?, as: :online expose :status @@ -1024,7 +1024,7 @@ module API expose :access_level expose :version, :revision, :platform, :architecture expose :contacted_at - expose :token, if: lambda { |runner, options| options[:current_user].admin? || !runner.is_shared? } + expose :token, if: lambda { |runner, options| options[:current_user].admin? || !runner.instance_type? } expose :projects, with: Entities::BasicProjectDetails do |runner, options| if options[:current_user].admin? runner.projects diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 96a02914faa..b4b984f7b8f 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -24,13 +24,13 @@ module API attributes = if runner_registration_token_valid? # Create shared runner. Requires admin access - attributes.merge(is_shared: true, runner_type: :instance_type) + attributes.merge(runner_type: :instance_type) elsif project = Project.find_by(runners_token: params[:token]) # Create a specific runner for the project - attributes.merge(is_shared: false, runner_type: :project_type, projects: [project]) + attributes.merge(runner_type: :project_type, projects: [project]) elsif group = Group.find_by(runners_token: params[:token]) # Create a specific runner for the group - attributes.merge(is_shared: false, runner_type: :group_type, groups: [group]) + attributes.merge(runner_type: :group_type, groups: [group]) else forbidden! end diff --git a/lib/api/runners.rb b/lib/api/runners.rb index 2b78075ddbf..2071c5a62c1 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -119,7 +119,7 @@ module API use :pagination end get ':id/runners' do - runners = filter_runners(Ci::Runner.owned_or_shared(user_project.id), params[:scope]) + runners = filter_runners(Ci::Runner.owned_or_instance_wide(user_project.id), params[:scope]) present paginate(runners), with: Entities::Runner end @@ -170,6 +170,11 @@ module API render_api_error!('Scope contains invalid value', 400) end + # Support deprecated scopes + if runners.respond_to?("deprecated_#{scope}") + scope = "deprecated_#{scope}" + end + runners.public_send(scope) # rubocop:disable GitlabSecurity/PublicSend end @@ -180,7 +185,7 @@ module API end def authenticate_show_runner!(runner) - return if runner.is_shared || current_user.admin? + return if runner.instance_type? || current_user.admin? forbidden!("No access granted") unless can?(current_user, :read_runner, runner) end |