diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-09 13:46:55 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-09 13:46:55 +0000 |
commit | 063b6b75be97440a96cda109bcb9d448920c7e49 (patch) | |
tree | 6232652b1559bcf872977e4a8da4c6ad10f6a290 | |
parent | b1b660528204189ae2c21af3543a2b6e32267735 (diff) | |
parent | a9b5f582f4e9e774615bf571527bafa8fc3a344a (diff) | |
download | gitlab-ce-063b6b75be97440a96cda109bcb9d448920c7e49.tar.gz |
Merge branch 'support-active-setting-while-registering-a-runner' into 'master'
Support 'active' setting on Runner Registration API endpoint
See merge request gitlab-org/gitlab-ce!18848
-rw-r--r-- | changelogs/unreleased/support-active-setting-while-registering-a-runner.yml | 5 | ||||
-rw-r--r-- | lib/api/runner.rb | 3 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 23 |
3 files changed, 30 insertions, 1 deletions
diff --git a/changelogs/unreleased/support-active-setting-while-registering-a-runner.yml b/changelogs/unreleased/support-active-setting-while-registering-a-runner.yml new file mode 100644 index 00000000000..6c378fd450a --- /dev/null +++ b/changelogs/unreleased/support-active-setting-while-registering-a-runner.yml @@ -0,0 +1,5 @@ +--- +title: Add support for 'active' setting on Runner Registration API endpoint +merge_request: 18848 +author: +type: changed diff --git a/lib/api/runner.rb b/lib/api/runner.rb index cd7d6603171..649feba1036 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -11,13 +11,14 @@ module API requires :token, type: String, desc: 'Registration token' optional :description, type: String, desc: %q(Runner's description) optional :info, type: Hash, desc: %q(Runner's metadata) + optional :active, type: Boolean, desc: 'Should Runner be active' optional :locked, type: Boolean, desc: 'Should Runner be locked for current project' optional :run_untagged, type: Boolean, desc: 'Should Runner handle untagged jobs' optional :tag_list, type: Array[String], desc: %q(List of Runner's tags) optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job' end post '/' do - attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :maximum_timeout]) + attributes = attributes_for_keys([:description, :active, :locked, :run_untagged, :tag_list, :maximum_timeout]) .merge(get_runner_details_from_request) runner = diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 082605827b7..da392c5ab81 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -41,6 +41,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do expect(json_response['id']).to eq(runner.id) expect(json_response['token']).to eq(runner.token) expect(runner.run_untagged).to be true + expect(runner.active).to be true expect(runner.token).not_to eq(registration_token) expect(runner).to be_instance_type end @@ -129,6 +130,28 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end end + context 'when option for activating a Runner is provided' do + context 'when active is set to true' do + it 'creates runner' do + post api('/runners'), token: registration_token, + active: true + + expect(response).to have_gitlab_http_status 201 + expect(Ci::Runner.first.active).to be true + end + end + + context 'when active is set to false' do + it 'creates runner' do + post api('/runners'), token: registration_token, + active: false + + expect(response).to have_gitlab_http_status 201 + expect(Ci::Runner.first.active).to be false + end + end + end + context 'when maximum job timeout is specified' do it 'creates runner' do post api('/runners'), token: registration_token, |