summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-24 01:28:57 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-03 23:49:10 +0900
commit6f19fc1147a60f279db35428993ac532841195ad (patch)
treee54e06487c4f13290890806df85d9272cb65a4ad
parentaf112c55e54874a37e780de6723c64e9be61b6e8 (diff)
downloadgitlab-ce-6f19fc1147a60f279db35428993ac532841195ad.tar.gz
Add API support
-rw-r--r--doc/api/runners.md9
-rw-r--r--lib/api/entities.rb1
-rw-r--r--lib/api/runners.rb3
-rw-r--r--spec/requests/api/runners_spec.rb4
4 files changed, 13 insertions, 4 deletions
diff --git a/doc/api/runners.md b/doc/api/runners.md
index 16d362a3530..dcca30dbfa7 100644
--- a/doc/api/runners.md
+++ b/doc/api/runners.md
@@ -138,7 +138,8 @@ Example response:
"ruby",
"mysql"
],
- "version": null
+ "version": null,
+ "access_level": 0
}
```
@@ -156,6 +157,9 @@ PUT /runners/:id
| `description` | string | no | The description of a runner |
| `active` | boolean | no | The state of a runner; can be set to `true` or `false` |
| `tag_list` | array | no | The list of tags for a runner; put array of tags, that should be finally assigned to a runner |
+| `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs |
+| `locked` | boolean | no | Flag indicating the runner is locked |
+| `access_level` | integer | no | The access_level of the runner; `unprotected`: 0, `protected`: 1 |
```
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
@@ -190,7 +194,8 @@ Example response:
"tag1",
"tag2"
],
- "version": null
+ "version": null,
+ "access_level": 0
}
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 9df9a515990..f13f2d723bb 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -775,6 +775,7 @@ module API
expose :tag_list
expose :run_untagged
expose :locked
+ expose :access_level
expose :version, :revision, :platform, :architecture
expose :contacted_at
expose :token, if: lambda { |runner, options| options[:current_user].admin? || !runner.is_shared? }
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index 1ea9a7918d7..d8fc44e5790 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -55,7 +55,8 @@ module API
optional :tag_list, type: Array[String], desc: 'The list of tags for a runner'
optional :run_untagged, type: Boolean, desc: 'Flag indicating the runner can execute untagged jobs'
optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked'
- at_least_one_of :description, :active, :tag_list, :run_untagged, :locked
+ optional :access_level, type: Integer, desc: 'The access_level of the runner'
+ at_least_one_of :description, :active, :tag_list, :run_untagged, :locked, :access_level
end
put ':id' do
runner = get_runner(params.delete(:id))
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 244895a417e..b8d98818a8c 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -191,7 +191,8 @@ describe API::Runners do
active: !active,
tag_list: ['ruby2.1', 'pgsql', 'mysql'],
run_untagged: 'false',
- locked: 'true')
+ locked: 'true',
+ access_level: 1)
shared_runner.reload
expect(response).to have_http_status(200)
@@ -200,6 +201,7 @@ describe API::Runners do
expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql')
expect(shared_runner.run_untagged?).to be(false)
expect(shared_runner.locked?).to be(true)
+ expect(shared_runner.protected_?).to be_truthy
expect(shared_runner.ensure_runner_queue_value)
.not_to eq(runner_queue_value)
end