Browse Source

Merge "Support latest as the microversion value"

tags/8.2.0
Zuul 7 months ago
parent
commit
73cbfc744b

+ 5
- 2
ironic_inspector/main.py View File

@@ -48,10 +48,13 @@ def _get_version():
48 48
     ver = flask.request.headers.get(conf_opts.VERSION_HEADER,
49 49
                                     _DEFAULT_API_VERSION)
50 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 55
     except (ValueError, TypeError):
53 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 58
     return requested
56 59
 
57 60
 

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

@@ -637,6 +637,12 @@ class TestApiVersions(BaseAPITest):
637 637
         self.assertIn('%d.%d' % main.MINIMUM_API_VERSION, error)
638 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
 
641 647
 class TestPlugins(unittest.TestCase):
642 648
     @mock.patch.object(example_plugin.ExampleProcessingHook,

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

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

Loading…
Cancel
Save