From 8a25cfa720e6fbc559d40dd095f819b0ba914823 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 12 Dec 2025 11:32:51 +0000 Subject: [PATCH] Handle single digit versions This matches the behavior of novaclient [1], cinderclient [2] etc. We also fix a typo. [1] https://github.com/openstack/python-novaclient/blob/3e2dd5bd638352ac453d975ec2194315d4daea8f/novaclient/api_versions.py#L233-L234 [2] https://github.com/openstack/python-cinderclient/blob/1d8c7becaf2c1363afe843d2a5a86b1707a8e3ff/cinderclient/api_versions.py#L227-L228 Change-Id: I91b46474366248ae34df27fe35f63281602ae377 Signed-off-by: Stephen Finucane --- manilaclient/api_versions.py | 4 ++++ manilaclient/osc/plugin.py | 2 +- manilaclient/tests/unit/test_api_versions.py | 5 ----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/manilaclient/api_versions.py b/manilaclient/api_versions.py index 621487917..e4b094a4b 100644 --- a/manilaclient/api_versions.py +++ b/manilaclient/api_versions.py @@ -18,6 +18,8 @@ import logging import re import warnings +from oslo_utils import strutils + import manilaclient from manilaclient.common._i18n import _ from manilaclient.common import cliutils @@ -231,6 +233,8 @@ def check_version_deprecated(api_version): def get_api_version(version_string): """Returns checked APIVersion object.""" version_string = str(version_string) + if strutils.is_int_like(version_string): + version_string = f"{version_string}.0" api_version = APIVersion(version_string) check_version_supported(api_version) diff --git a/manilaclient/osc/plugin.py b/manilaclient/osc/plugin.py index 65acb7618..63495ded5 100644 --- a/manilaclient/osc/plugin.py +++ b/manilaclient/osc/plugin.py @@ -121,7 +121,7 @@ def build_option_parser(parser): ), help='Shared File System API version, default=' + default_api_version - + 'version supported by both the client and the server). ' + + ' (version supported by both the client and the server) ' '(Env: OS_SHARE_API_VERSION)', ) parser.add_argument( diff --git a/manilaclient/tests/unit/test_api_versions.py b/manilaclient/tests/unit/test_api_versions.py index f71cfaa2b..2a1ce4bcb 100644 --- a/manilaclient/tests/unit/test_api_versions.py +++ b/manilaclient/tests/unit/test_api_versions.py @@ -144,11 +144,6 @@ class GetAPIVersionTestCase(utils.TestCase): "something_wrong", ) - def test_wrong_major_version(self): - self.assertRaises( - exceptions.UnsupportedVersion, api_versions.get_api_version, "1" - ) - @mock.patch("manilaclient.api_versions.APIVersion") def test_major_and_minor_parts_is_presented(self, mock_apiversion): version = "2.7"