Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-09-14 12:03:44 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-09-14 12:03:44 +0300
commit55c23a09352e8e6b4d0059ad47a76426bb0d7799 (patch)
tree2560a5fd450ebd2a5d19398786f6a9067984dd8e /lib
parentf076358491400008dfaa1c4b4c545acc66236706 (diff)
parentf7ef78a7b5529a345d06b31df067f73c0b6c5833 (diff)
Merge branch 'feature/runner-state-filter-for-admin-view' into 'master'
Feature: State filter for admin runners view See merge request gitlab-org/gitlab-ce!19625
Diffstat (limited to 'lib')
-rw-r--r--lib/api/runners.rb17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index f35cf521e0a..30abd0b63e9 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: Ci::Runner::AVAILABLE_STATUSES,
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], allowed_scopes: 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: Ci::Runner::AVAILABLE_SCOPES,
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: Ci::Runner::AVAILABLE_SCOPES,
desc: 'The scope of specific runners to show'
use :pagination
end
@@ -160,15 +160,10 @@ module API
end
helpers do
- def filter_runners(runners, scope, options = {})
+ def filter_runners(runners, scope, allowed_scopes: ::Ci::Runner::AVAILABLE_SCOPES)
return runners unless scope.present?
- available_scopes = ::Ci::Runner::AVAILABLE_SCOPES
- if options[:without]
- available_scopes = available_scopes - options[:without]
- end
-
- if (available_scopes & [scope]).empty?
+ unless allowed_scopes.include?(scope)
render_api_error!('Scope contains invalid value', 400)
end