Browse Source

Merge "Support latest as the microversion value"

tags/8.2.0
Zuul 1 year ago
parent
commit
73cbfc744b
3 changed files with 16 additions and 2 deletions
  1. +5
    -2
      ironic_inspector/main.py
  2. +6
    -0
      ironic_inspector/test/unit/test_main.py
  3. +5
    -0
      releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml

+ 5
- 2
ironic_inspector/main.py View File

@@ -48,10 +48,13 @@ def _get_version():
ver = flask.request.headers.get(conf_opts.VERSION_HEADER,
_DEFAULT_API_VERSION)
try:
requested = tuple(int(x) for x in ver.split('.'))
if ver.lower() == 'latest':
requested = CURRENT_API_VERSION
else:
requested = tuple(int(x) for x in ver.split('.'))
except (ValueError, TypeError):
return error_response(_('Malformed API version: expected string '
'in form of X.Y'), code=400)
'in form of X.Y or latest'), code=400)
return requested



+ 6
- 0
ironic_inspector/test/unit/test_main.py View File

@@ -637,6 +637,12 @@ class TestApiVersions(BaseAPITest):
self.assertIn('%d.%d' % main.MINIMUM_API_VERSION, error)
self.assertIn('%d.%d' % main.CURRENT_API_VERSION, error)

def test_request_latest_version(self):
headers = {conf_opts.VERSION_HEADER: 'latest'}
res = self.app.get('/', headers=headers)
self.assertEqual(200, res.status_code)
self._check_version_present(res)


class TestPlugins(unittest.TestCase):
@mock.patch.object(example_plugin.ExampleProcessingHook,

+ 5
- 0
releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml View File

@@ -0,0 +1,5 @@
---
features:
- |
Adds support to use ``latest`` as the microversion value in the request
to the ironic-inspector API.

Loading…
Cancel
Save