Commit a2e0d2f8 authored by Patrick Bair's avatar Patrick Bair

Merge branch 'pedropombeiro/350730-rename-maintainer-note-field' into 'master'

Deprecate Runner REST API maintainer_note with maintenance_note

See merge request gitlab-org/gitlab!78677
parents 0e9ab359 1f56df9b
......@@ -212,7 +212,9 @@ module Ci
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.
#
......
......@@ -574,7 +574,7 @@ POST /runners
```
| Attribute | Type | Required | Description |
|-------------------|----------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|--------------------|--------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `token` | string | yes | [Registration token](#registration-and-authentication-tokens). |
| `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. |
......@@ -584,7 +584,8 @@ POST /runners
| `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` |
| `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
curl --request POST "https://gitlab.example.com/api/v4/runners" \
......
......@@ -100,7 +100,7 @@ RSpec.describe API::Ci::Runner do
context 'job has secrets configured' do
let(:secrets) { valid_secrets }
it 'doesn not return secrets configuration' do
it 'does not return secrets configuration' do
request_job_with_secrets_supported
expect(response).to have_gitlab_http_status(:created)
......
......@@ -15,7 +15,8 @@ module API
params do
requires :token, type: String, desc: 'Registration token'
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 :active, type: Boolean, desc: 'Should Runner be active'
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
......@@ -26,9 +27,13 @@ module API
optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
end
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)
# 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)
forbidden! unless @runner
......
......@@ -30,7 +30,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
post api('/runners'), params: {
token: 'valid token',
description: 'server.hostname',
maintainer_note: 'Some maintainer notes',
maintenance_note: 'Some maintainer notes',
run_untagged: false,
tag_list: 'tag1, tag2',
locked: true,
......@@ -46,7 +46,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
allow_next_instance_of(::Ci::RegisterRunnerService) do |service|
expected_params = {
description: 'server.hostname',
maintainer_note: 'Some maintainer notes',
maintenance_note: 'Some maintainer notes',
run_untagged: false,
tag_list: %w(tag1 tag2),
locked: true,
......@@ -81,6 +81,33 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
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
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