diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-07 11:40:11 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-07 11:40:11 -0800 |
commit | 525b8c5da1eb3ae9de9656f6c5cf7b1b55f5c8d9 (patch) | |
tree | 4cb0065253107a975e5591d19d0ea7dabd5388e2 /lib | |
parent | 7693baea93c5104dc6fdddff2dad7d69ddf3631f (diff) | |
download | gitlab-ci-525b8c5da1eb3ae9de9656f6c5cf7b1b55f5c8d9.tar.gz |
Add ability to register specific runners for projects
You can provide project token durinng runner regstration and runner will
be created specifically for this project
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/runners.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index ef78b09..f8239a1 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -28,10 +28,18 @@ module API # Example Request: # POST /runners/register post "register" do - authenticate_runners! required_attributes! [:token] - runner = Runner.create + runner = + if params[:token] == GitlabCi::REGISTRATION_TOKEN + # Create shared runner. Requires admin access + Runner.create + elsif project = Project.find_by(token: params[:token]) + # Create a specific runner for project. + project.runners.create + end + + return forbidden! unless runner if runner.id present runner, with: Entities::Runner |