summaryrefslogtreecommitdiff
path: root/lib/api/runners.rb
diff options
context:
space:
mode:
authorAlexis Reigel <alexis.reigel.ext@siemens.com>2018-06-06 15:55:14 +0200
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-08-20 17:12:18 +0200
commitf0d0400d0be6948f769c8733386ed765a04d23b2 (patch)
treedb510ee9966ab62a1353bc1e6ccce863a5944202 /lib/api/runners.rb
parent00647b31b4741102451a2d785a43ef14bb818e24 (diff)
downloadgitlab-ce-f0d0400d0be6948f769c8733386ed765a04d23b2.tar.gz
add Ci::Runner.offline scope to API
Diffstat (limited to 'lib/api/runners.rb')
-rw-r--r--lib/api/runners.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index 51242341dba..bf9cd6234a3 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -9,12 +9,12 @@ module API
success Entities::Runner
end
params do
- optional :scope, type: String, values: %w[active paused online],
+ optional :scope, type: String, values: %w[active paused online offline],
desc: 'The scope of specific runners to show'
use :pagination
end
get do
- runners = filter_runners(current_user.ci_owned_runners, params[:scope], without: %w(specific shared))
+ runners = filter_runners(current_user.ci_owned_runners, params[:scope], only: Ci::Runner::AVAILABLE_STATUSES)
present paginate(runners), with: Entities::Runner
end
@@ -22,7 +22,7 @@ module API
success Entities::Runner
end
params do
- optional :scope, type: String, values: %w[active paused online specific shared],
+ optional :scope, type: String, values: %w[active paused online offline specific shared],
desc: 'The scope of specific runners to show'
use :pagination
end
@@ -114,7 +114,7 @@ module API
success Entities::Runner
end
params do
- optional :scope, type: String, values: %w[active paused online specific shared],
+ optional :scope, type: String, values: %w[active paused online offline specific shared],
desc: 'The scope of specific runners to show'
use :pagination
end
@@ -158,15 +158,12 @@ module API
end
helpers do
- def filter_runners(runners, scope, options = {})
+ def filter_runners(runners, scope, only: nil)
return runners unless scope.present?
- available_scopes = ::Ci::Runner::AVAILABLE_SCOPES
- if options[:without]
- available_scopes = available_scopes - options[:without]
- end
+ available_scopes = only || ::Ci::Runner::AVAILABLE_SCOPES
- if (available_scopes & [scope]).empty?
+ unless available_scopes.include?(scope)
render_api_error!('Scope contains invalid value', 400)
end