Merge "Follow-up: Use ``microversion-parse`` to parse version headers in API requests"

This commit is contained in:
Zuul 2024-04-19 15:52:31 +00:00 committed by Gerrit Code Review
commit 3c5b4cb349
3 changed files with 17 additions and 1 deletions

View File

@ -12,10 +12,15 @@ supports versioning. There are two kinds of versions in Ironic.
- ''major versions'', which have dedicated urls.
- ''microversions'', which can be requested through the use of the
``X-OpenStack-Ironic-API-Version`` header.
``X-OpenStack-Ironic-API-Version`` header or the new standard singular header
``OpenStack-API-Version: baremetal <version>``.
The Version APIs work differently from other APIs as they *do not* require authentication.
Upon the Dalmatian release, all API requests support the
new standard singular header ``OpenStack-API-Version: baremetal <version>``.
If that's not present, we fall back to the legacy headers.
Beginning with the Kilo release, all API requests support the
``X-OpenStack-Ironic-API-Version`` header. This header SHOULD be supplied
with every request; in the absence of this header, each request is treated

View File

@ -71,6 +71,11 @@ class TestVersion(base.BaseApiTest):
{cbase.Version.string: '123.456'}, mock.ANY, mock.ANY)
self.assertEqual((123, 456), version)
def test_parse_new_standard_singular_header_ok(self):
version = cbase.Version.parse_headers(
{'OpenStack-API-Version': 'baremetal 123.456'}, mock.ANY, mock.ANY)
self.assertEqual((123, 456), version)
def test_parse_headers_latest(self):
for s in ['latest', 'LATEST']:
version = cbase.Version.parse_headers(

View File

@ -0,0 +1,6 @@
---
features:
- |
Delegate parsing of version headers in API requests to the
``microversion-parse`` library which also adds support for the new
standard singular header: 'OpenStack-API-Version: baremetal <version>'.