diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-07-19 23:33:42 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-07-19 23:33:42 +0200 |
commit | bf9db45a1dc4d8269fa68dc27dac6667c89ffda8 (patch) | |
tree | 813d6c8151c156d186cdf4e3420f42260d206434 /lib/api/runners.rb | |
parent | 0aedeb5637932fa827e42be7441e9c967049dd1d (diff) | |
parent | b9ed9d658ad447a64d58b2040849a7cc0e698287 (diff) | |
download | gitlab-ce-bf9db45a1dc4d8269fa68dc27dac6667c89ffda8.tar.gz |
Merge remote-tracking branch 'origin/master' into ci-predefined-variables
Diffstat (limited to 'lib/api/runners.rb')
-rw-r--r-- | lib/api/runners.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index 4faba9dc87b..ecc8f2fc5a2 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -49,7 +49,7 @@ module API runner = get_runner(params[:id]) authenticate_update_runner!(runner) - attrs = attributes_for_keys [:description, :active, :tag_list, :run_untagged] + attrs = attributes_for_keys [:description, :active, :tag_list, :run_untagged, :locked] if runner.update(attrs) present runner, with: Entities::RunnerDetails, current_user: current_user else @@ -96,9 +96,14 @@ module API runner = get_runner(params[:runner_id]) authenticate_enable_runner!(runner) - Ci::RunnerProject.create(runner: runner, project: user_project) - present runner, with: Entities::Runner + runner_project = runner.assign_to(user_project) + + if runner_project.persisted? + present runner, with: Entities::Runner + else + conflict!("Runner was already enabled for this project") + end end # Disable project's runner @@ -163,6 +168,7 @@ module API def authenticate_enable_runner!(runner) forbidden!("Runner is shared") if runner.is_shared? + forbidden!("Runner is locked") if runner.locked? return if current_user.is_admin? forbidden!("No access granted") unless user_can_access_runner?(runner) end |