diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-12 19:26:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-12 19:26:10 +0300 |
commit | 6653ccc011dec86e5140a5d09ea3b2357eab6714 (patch) | |
tree | 897193f37bcd98152a0ac214f80a3c4cfe1047c5 /lib/api/ci/runner.rb | |
parent | bff35a05aed6a31380a73c39113808fd262c2c37 (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc41
Diffstat (limited to 'lib/api/ci/runner.rb')
-rw-r--r-- | lib/api/ci/runner.rb | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb index 5cfb65e1fbb..80d5e80e21e 100644 --- a/lib/api/ci/runner.rb +++ b/lib/api/ci/runner.rb @@ -34,22 +34,22 @@ module API if runner_registration_token_valid? # Create shared runner. Requires admin access attributes.merge(runner_type: :instance_type) - elsif project = Project.find_by_runners_token(params[:token]) + elsif @project = Project.find_by_runners_token(params[:token]) # Create a specific runner for the project - attributes.merge(runner_type: :project_type, projects: [project]) - elsif group = Group.find_by_runners_token(params[:token]) + 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(runner_type: :group_type, groups: [group]) + attributes.merge(runner_type: :group_type, groups: [@group]) else forbidden! end - runner = ::Ci::Runner.create(attributes) + @runner = ::Ci::Runner.create(attributes) - if runner.persisted? - present runner, with: Entities::RunnerRegistrationDetails + if @runner.persisted? + present @runner, with: Entities::RunnerRegistrationDetails else - render_validation_error!(runner) + render_validation_error!(@runner) end end @@ -62,9 +62,7 @@ module API delete '/' do authenticate_runner! - runner = ::Ci::Runner.find_by_token(params[:token]) - - destroy_conditionally!(runner) + destroy_conditionally!(current_runner) end desc 'Validates authentication credentials' do @@ -81,12 +79,7 @@ module API end resource :jobs do - before do - Gitlab::ApplicationContext.push( - user: -> { current_job&.user }, - project: -> { current_job&.project } - ) - end + before { set_application_context } desc 'Request a job' do success Entities::JobRequest::Response |