summaryrefslogtreecommitdiff
path: root/lib/api/helpers
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-02-14 23:52:02 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-02-16 01:16:41 +0100
commit618ce941647177b560fb3f5b677325bb964edae3 (patch)
tree580ef62f72af092ef8fec9ce6a216d4afe11a5a0 /lib/api/helpers
parentb05e75b8faccc50749adc63419074c91802a8f50 (diff)
downloadgitlab-ce-618ce941647177b560fb3f5b677325bb964edae3.tar.gz
Add Runner registration/deletion API
Diffstat (limited to 'lib/api/helpers')
-rw-r--r--lib/api/helpers/ci.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/helpers/ci.rb b/lib/api/helpers/ci.rb
new file mode 100644
index 00000000000..24669eba4bb
--- /dev/null
+++ b/lib/api/helpers/ci.rb
@@ -0,0 +1,24 @@
+module API
+ module Helpers
+ module Ci
+ def runner_registration_token_valid?
+ ActiveSupport::SecurityUtils.variable_size_secure_compare(
+ params[:token],
+ current_application_settings.runners_registration_token)
+ end
+
+ def get_runner_version_from_params
+ return unless params['info'].present?
+ attributes_for_keys(%w(name version revision platform architecture), params['info'])
+ end
+
+ def authenticate_runner!
+ forbidden! unless current_runner
+ end
+
+ def current_runner
+ @runner ||= ::Ci::Runner.find_by_token(params[:token].to_s)
+ end
+ end
+ end
+end \ No newline at end of file