Commit 1bbf2c2c authored by Tomasz Maczukin's avatar Tomasz Maczukin

Fix rubocop offenses

parent f7d35234
module API module API
module Helpers module Helpers
module Runner module Runner
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN' JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
JOB_TOKEN_PARAM = :token JOB_TOKEN_PARAM = :token
UPDATE_RUNNER_EVERY = 10 * 60 UPDATE_RUNNER_EVERY = 10 * 60
...@@ -42,7 +42,7 @@ module API ...@@ -42,7 +42,7 @@ module API
end end
def job_not_found! def job_not_found!
if headers['User-Agent'].to_s.match(/gitlab(-ci-multi)?-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /) if headers['User-Agent'].to_s =~ /gitlab(-ci-multi)?-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /
no_content! no_content!
else else
not_found! not_found!
......
...@@ -94,7 +94,7 @@ module API ...@@ -94,7 +94,7 @@ module API
end end
params do params do
requires :token, type: String, desc: %q(Runners's authentication token) requires :token, type: String, desc: %q(Runners's authentication token)
requires :id, type: Fixnum, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :trace, type: String, desc: %q(Job's full trace) optional :trace, type: String, desc: %q(Job's full trace)
optional :state, type: String, desc: %q(Job's status: success, failed) optional :state, type: String, desc: %q(Job's status: success, failed)
end end
...@@ -122,7 +122,7 @@ module API ...@@ -122,7 +122,7 @@ module API
[416, 'Range not satisfiable']] [416, 'Range not satisfiable']]
end end
params do params do
requires :id, type: Fixnum, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token) optional :token, type: String, desc: %q(Job's authentication token)
end end
patch '/:id/trace' do patch '/:id/trace' do
...@@ -152,9 +152,9 @@ module API ...@@ -152,9 +152,9 @@ module API
[413, 'File too large']] [413, 'File too large']]
end end
params do params do
requires :id, type: Fixnum, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token) optional :token, type: String, desc: %q(Job's authentication token)
optional :filesize, type: Fixnum, desc: %q(ARtifacts filesize) optional :filesize, type: Integer, desc: %q(Artifacts filesize)
end end
post '/:id/artifacts/authorize' do post '/:id/artifacts/authorize' do
not_allowed! unless Gitlab.config.artifacts.enabled not_allowed! unless Gitlab.config.artifacts.enabled
...@@ -183,7 +183,7 @@ module API ...@@ -183,7 +183,7 @@ module API
[413, 'File too large']] [413, 'File too large']]
end end
params do params do
requires :id, type: Fixnum, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token) optional :token, type: String, desc: %q(Job's authentication token)
optional :expire_in, type: String, desc: %q(Specify when artifacts should expire) optional :expire_in, type: String, desc: %q(Specify when artifacts should expire)
optional 'file', type: File, desc: %q(Artifact's file) optional 'file', type: File, desc: %q(Artifact's file)
...@@ -211,9 +211,7 @@ module API ...@@ -211,9 +211,7 @@ module API
job.artifacts_file = artifacts job.artifacts_file = artifacts
job.artifacts_metadata = metadata job.artifacts_metadata = metadata
job.artifacts_expire_in = params['expire_in'] || job.artifacts_expire_in = params['expire_in'] ||
Gitlab::CurrentSettings Gitlab::CurrentSettings.current_application_settings.default_artifacts_expire_in
.current_application_settings
.default_artifacts_expire_in
if job.save if job.save
present job, with: Entities::JobRequest::Response present job, with: Entities::JobRequest::Response
...@@ -228,7 +226,7 @@ module API ...@@ -228,7 +226,7 @@ module API
[404, 'Artifact not found']] [404, 'Artifact not found']]
end end
params do params do
requires :id, type: Fixnum, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token) optional :token, type: String, desc: %q(Job's authentication token)
end end
get '/:id/artifacts' do get '/:id/artifacts' do
......
...@@ -3,9 +3,9 @@ module Gitlab ...@@ -3,9 +3,9 @@ module Gitlab
module Build module Build
module Response module Response
class Step class Step
CONDITION_ON_FAILURE = 'on_failure' CONDITION_ON_FAILURE = 'on_failure'.freeze
CONDITION_ON_SUCCESS = 'on_success' CONDITION_ON_SUCCESS = 'on_success'.freeze
CONDITION_ALWAYS = 'always' CONDITION_ALWAYS = 'always'.freeze
attr_reader :name, :script, :when, :allow_failure, :timeout attr_reader :name, :script, :when, :allow_failure, :timeout
......
...@@ -281,7 +281,7 @@ describe API::Runner do ...@@ -281,7 +281,7 @@ describe API::Runner do
expect(json_response['image']).to include({ 'name' => 'ruby:2.1' }) expect(json_response['image']).to include({ 'name' => 'ruby:2.1' })
expect(json_response['services']).to include({ 'name' => 'postgres' }) expect(json_response['services']).to include({ 'name' => 'postgres' })
expect(json_response['steps']).to include({ 'name' => 'after_script', expect(json_response['steps']).to include({ 'name' => 'after_script',
'script' => ['ls', 'date'], 'script' => %w(ls date),
'timeout' => job.timeout, 'timeout' => job.timeout,
'when' => 'always', 'when' => 'always',
'allow_failure' => true }) 'allow_failure' => true })
...@@ -889,9 +889,11 @@ describe API::Runner do ...@@ -889,9 +889,11 @@ describe API::Runner do
end end
def upload_artifacts(file, headers = {}, accelerated = true) def upload_artifacts(file, headers = {}, accelerated = true)
params = accelerated ? params = if accelerated
{ 'file.path' => file.path, 'file.name' => file.original_filename } : { 'file.path' => file.path, 'file.name' => file.original_filename }
else
{ 'file' => file } { 'file' => file }
end
post api("/jobs/#{job.id}/artifacts"), params, headers post api("/jobs/#{job.id}/artifacts"), params, headers
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment