diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/runners.rb | 17 |
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 |