Commit 1f56df9b authored by Pedro Pombeiro's avatar Pedro Pombeiro

Deprecate Runner API maintainer_note

Replace with maintenance_note

Changelog: deprecated
parent 95124bea
...@@ -210,7 +210,9 @@ module Ci ...@@ -210,7 +210,9 @@ module Ci
validates :config, json_schema: { filename: 'ci_runner_config' } validates :config, json_schema: { filename: 'ci_runner_config' }
validates :maintainer_note, length: { maximum: 255 } validates :maintenance_note, length: { maximum: 255 }
alias_attribute :maintenance_note, :maintainer_note
# Searches for runners matching the given query. # Searches for runners matching the given query.
# #
......
...@@ -574,7 +574,7 @@ POST /runners ...@@ -574,7 +574,7 @@ 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. |
...@@ -584,7 +584,8 @@ POST /runners ...@@ -584,7 +584,8 @@ 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) | | `maintainer_note` | string | no | [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/350730), see `maintenance_note`. |
| `maintenance_note` | string | no | Free-form maintenance 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" \
......
...@@ -100,7 +100,7 @@ RSpec.describe API::Ci::Runner do ...@@ -100,7 +100,7 @@ RSpec.describe API::Ci::Runner do
context 'job has secrets configured' do context 'job has secrets configured' do
let(:secrets) { valid_secrets } let(:secrets) { valid_secrets }
it 'doesn not return secrets configuration' do it 'does not return secrets configuration' do
request_job_with_secrets_supported request_job_with_secrets_supported
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
......
...@@ -15,7 +15,8 @@ module API ...@@ -15,7 +15,8 @@ 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 :maintainer_note, type: String, desc: %q(Deprecated: Use :maintenance_note instead. Runner's maintenance notes)
optional :maintenance_note, type: String, desc: %q(Runner's maintenance 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'
...@@ -26,9 +27,13 @@ module API ...@@ -26,9 +27,13 @@ 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(%i[description maintainer_note active locked run_untagged tag_list access_level maximum_timeout]) attributes = attributes_for_keys(%i[description maintainer_note maintenance_note active locked run_untagged tag_list access_level maximum_timeout])
.merge(get_runner_details_from_request) .merge(get_runner_details_from_request)
# Pull in deprecated maintainer_note if that's the only note value available
deprecated_note = attributes.delete(:maintainer_note)
attributes[:maintenance_note] ||= deprecated_note if deprecated_note
@runner = ::Ci::RegisterRunnerService.new.execute(params[:token], attributes) @runner = ::Ci::RegisterRunnerService.new.execute(params[:token], attributes)
forbidden! unless @runner forbidden! unless @runner
......
...@@ -30,7 +30,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -30,7 +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', maintenance_note: 'Some maintainer notes',
run_untagged: false, run_untagged: false,
tag_list: 'tag1, tag2', tag_list: 'tag1, tag2',
locked: true, locked: true,
...@@ -46,7 +46,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -46,7 +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', maintenance_note: 'Some maintainer notes',
run_untagged: false, run_untagged: false,
tag_list: %w(tag1 tag2), tag_list: %w(tag1 tag2),
locked: true, locked: true,
...@@ -81,6 +81,33 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -81,6 +81,33 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end end
end end
context 'when deprecated maintainer_note field is provided' do
RSpec::Matchers.define_negated_matcher :excluding, :include
def request
post api('/runners'), params: {
token: 'valid token',
maintainer_note: 'Some maintainer notes'
}
end
let(:new_runner) { create(:ci_runner) }
it 'converts to maintenance_note param' do
allow_next_instance_of(::Ci::RegisterRunnerService) do |service|
expect(service).to receive(:execute)
.once
.with('valid token', a_hash_including('maintenance_note' => 'Some maintainer notes')
.and(excluding('maintainter_note' => anything)))
.and_return(new_runner)
end
request
expect(response).to have_gitlab_http_status(:created)
end
end
context 'calling actual register service' do context 'calling actual register service' do
include StubGitlabCalls include StubGitlabCalls
......
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