summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-06 19:28:27 +0000
committerGerrit Code Review <review@openstack.org>2019-02-06 19:28:27 +0000
commit73cbfc744bf75fb0a68c642ac486afbaf5f4f8e7 (patch)
treea17b8b7fb2df76a2733bd3d385c68406d112084d
parent13e70283b13e1c4e65a965197f23709ce9343e80 (diff)
parent04ee0bc031d4396baa24f068ee8f493bd18de979 (diff)
Merge "Support latest as the microversion value"
-rw-r--r--ironic_inspector/main.py7
-rw-r--r--ironic_inspector/test/unit/test_main.py6
-rw-r--r--releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml5
3 files changed, 16 insertions, 2 deletions
diff --git a/ironic_inspector/main.py b/ironic_inspector/main.py
index ebaf016..ca3f62a 100644
--- a/ironic_inspector/main.py
+++ b/ironic_inspector/main.py
@@ -48,10 +48,13 @@ def _get_version():
48 ver = flask.request.headers.get(conf_opts.VERSION_HEADER, 48 ver = flask.request.headers.get(conf_opts.VERSION_HEADER,
49 _DEFAULT_API_VERSION) 49 _DEFAULT_API_VERSION)
50 try: 50 try:
51 requested = tuple(int(x) for x in ver.split('.')) 51 if ver.lower() == 'latest':
52 requested = CURRENT_API_VERSION
53 else:
54 requested = tuple(int(x) for x in ver.split('.'))
52 except (ValueError, TypeError): 55 except (ValueError, TypeError):
53 return error_response(_('Malformed API version: expected string ' 56 return error_response(_('Malformed API version: expected string '
54 'in form of X.Y'), code=400) 57 'in form of X.Y or latest'), code=400)
55 return requested 58 return requested
56 59
57 60
diff --git a/ironic_inspector/test/unit/test_main.py b/ironic_inspector/test/unit/test_main.py
index c1b45e1..892231b 100644
--- a/ironic_inspector/test/unit/test_main.py
+++ b/ironic_inspector/test/unit/test_main.py
@@ -637,6 +637,12 @@ class TestApiVersions(BaseAPITest):
637 self.assertIn('%d.%d' % main.MINIMUM_API_VERSION, error) 637 self.assertIn('%d.%d' % main.MINIMUM_API_VERSION, error)
638 self.assertIn('%d.%d' % main.CURRENT_API_VERSION, error) 638 self.assertIn('%d.%d' % main.CURRENT_API_VERSION, error)
639 639
640 def test_request_latest_version(self):
641 headers = {conf_opts.VERSION_HEADER: 'latest'}
642 res = self.app.get('/', headers=headers)
643 self.assertEqual(200, res.status_code)
644 self._check_version_present(res)
645
640 646
641class TestPlugins(unittest.TestCase): 647class TestPlugins(unittest.TestCase):
642 @mock.patch.object(example_plugin.ExampleProcessingHook, 648 @mock.patch.object(example_plugin.ExampleProcessingHook,
diff --git a/releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml b/releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml
new file mode 100644
index 0000000..274fc68
--- /dev/null
+++ b/releasenotes/notes/support-microversion-latest-dcf9598c5218e979.yaml
@@ -0,0 +1,5 @@
1---
2features:
3 - |
4 Adds support to use ``latest`` as the microversion value in the request
5 to the ironic-inspector API. \ No newline at end of file