Handle single digit versions

This matches the behavior of novaclient [1], cinderclient [2] etc.

We also fix a typo.

[1] 3e2dd5bd63/novaclient/api_versions.py (L233-L234)
[2] 1d8c7becaf/cinderclient/api_versions.py (L227-L228)

Change-Id: I91b46474366248ae34df27fe35f63281602ae377
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane
2025-12-12 11:32:51 +00:00
committed by Goutham Pacha Ravi
parent 6ecb5c13a0
commit 8a25cfa720
3 changed files with 5 additions and 6 deletions

View File

@@ -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)

View File

@@ -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(

View File

@@ -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"