Commit 7924137d authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'pedropombeiro/348299/2-add-notes-param-in-rest-api' into 'master'

Accept maintainer_note parameter in REST runner registration

See merge request gitlab-org/gitlab!77779
parents a54e0346 574e6f6e
...@@ -574,9 +574,9 @@ POST /runners ...@@ -574,9 +574,9 @@ POST /runners
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
|--------------|---------|----------|---------------------| |-------------------|----------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `token` | string | yes | [Registration token](#registration-and-authentication-tokens). | | `token` | string | yes | [Registration token](#registration-and-authentication-tokens). |
| `description`| string | no | Runner's description| | `description` | string | no | Runner's description |
| `info` | hash | no | Runner's metadata. You can include `name`, `version`, `revision`, `platform`, and `architecture`, but only `version` is displayed in the Admin area of the UI. | | `info` | hash | no | Runner's metadata. You can include `name`, `version`, `revision`, `platform`, and `architecture`, but only `version` is displayed in the Admin area of the UI. |
| `active` | boolean | no | Whether the runner is active | | `active` | boolean | no | Whether the runner is active |
| `locked` | boolean | no | Whether the runner should be locked for current project | | `locked` | boolean | no | Whether the runner should be locked for current project |
...@@ -584,6 +584,7 @@ POST /runners ...@@ -584,6 +584,7 @@ POST /runners
| `tag_list` | string array | no | List of runner's tags | | `tag_list` | string array | no | List of runner's tags |
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` | | `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
| `maximum_timeout` | integer | no | Maximum timeout set when this runner handles the job | | `maximum_timeout` | integer | no | Maximum timeout set when this runner handles the job |
| `maintainer_note` | string | no | Free-form maintainer notes for the runner (255 characters) |
```shell ```shell
curl --request POST "https://gitlab.example.com/api/v4/runners" \ curl --request POST "https://gitlab.example.com/api/v4/runners" \
......
...@@ -15,6 +15,7 @@ module API ...@@ -15,6 +15,7 @@ module API
params do params do
requires :token, type: String, desc: 'Registration token' requires :token, type: String, desc: 'Registration token'
optional :description, type: String, desc: %q(Runner's description) optional :description, type: String, desc: %q(Runner's description)
optional :maintainer_note, type: String, desc: %q(Runner's maintainer notes)
optional :info, type: Hash, desc: %q(Runner's metadata) optional :info, type: Hash, desc: %q(Runner's metadata)
optional :active, type: Boolean, desc: 'Should Runner be active' optional :active, type: Boolean, desc: 'Should Runner be active'
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project' optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
...@@ -25,7 +26,7 @@ module API ...@@ -25,7 +26,7 @@ module API
optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job' optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
end end
post '/', feature_category: :runner do post '/', feature_category: :runner do
attributes = attributes_for_keys([:description, :active, :locked, :run_untagged, :tag_list, :access_level, :maximum_timeout]) attributes = attributes_for_keys(%i[description maintainer_note active locked run_untagged tag_list access_level maximum_timeout])
.merge(get_runner_details_from_request) .merge(get_runner_details_from_request)
@runner = ::Ci::RegisterRunnerService.new.execute(params[:token], attributes) @runner = ::Ci::RegisterRunnerService.new.execute(params[:token], attributes)
......
...@@ -30,6 +30,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -30,6 +30,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
post api('/runners'), params: { post api('/runners'), params: {
token: 'valid token', token: 'valid token',
description: 'server.hostname', description: 'server.hostname',
maintainer_note: 'Some maintainer notes',
run_untagged: false, run_untagged: false,
tag_list: 'tag1, tag2', tag_list: 'tag1, tag2',
locked: true, locked: true,
...@@ -45,6 +46,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -45,6 +46,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
allow_next_instance_of(::Ci::RegisterRunnerService) do |service| allow_next_instance_of(::Ci::RegisterRunnerService) do |service|
expected_params = { expected_params = {
description: 'server.hostname', description: 'server.hostname',
maintainer_note: 'Some maintainer notes',
run_untagged: false, run_untagged: false,
tag_list: %w(tag1 tag2), tag_list: %w(tag1 tag2),
locked: true, locked: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment