gitlab-org--gitlab-foss/lib/ci/api/helpers.rb

34 lines
955 B
Ruby
Raw Normal View History

2015-08-26 01:42:46 +00:00
module Ci
module API
module Helpers
def authenticate_runners!
forbidden! unless params[:token] == GitlabCi::REGISTRATION_TOKEN
end
def authenticate_runner!
forbidden! unless current_runner
end
def authenticate_project_token!(project)
forbidden! unless project.valid_token?(params[:project_token])
end
def update_runner_last_contact
if current_runner.contacted_at.nil? || Time.now - current_runner.contacted_at >= UPDATE_RUNNER_EVERY
current_runner.update_attributes(contacted_at: Time.now)
end
end
2015-09-14 15:14:17 +00:00
def current_runner
@runner ||= Runner.find_by_token(params[:token].to_s)
end
2015-08-26 01:42:46 +00:00
def update_runner_info
return unless params["info"].present?
info = attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"])
current_runner.update(info)
end
end
end
end