diff --git a/build.py b/build.py index 2ca116a..2038c0d 100644 --- a/build.py +++ b/build.py @@ -55,7 +55,7 @@ def set_properties(project): project.depends_on("openapi-spec-validator", "~=0.3") project.depends_on("json-log-formatter", "~=0.3") project.depends_on("platformdirs", "~=4.2") - project.depends_on("requests", "~=2.25") + project.depends_on("requests", "~=2.31.0") project.depends_on("jsonpatch", "~=1.32") project.depends_on("jsonpath-ng", "~=1.6.1") project.depends_on("jinja2", "~=3.1") diff --git a/src/integrationtest/python/full_smoke_tests.py b/src/integrationtest/python/full_smoke_tests.py index b010425..1a1467c 100644 --- a/src/integrationtest/python/full_smoke_tests.py +++ b/src/integrationtest/python/full_smoke_tests.py @@ -29,7 +29,7 @@ def test_full_smoke(self): test_dir = Path(__file__).parent / "full_smoke" for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[0], "1.10.6"), - (self.K8S_TEST_VERSIONS[-1], "1.20.0")): + (self.K8S_TEST_VERSIONS[-1], "1.22.0")): with self.subTest(k8s_version=k8s_version, istio_version=istio_version): os.environ["K8S_VERSION"] = k8s_version os.environ["ISTIO_VERSION"] = istio_version diff --git a/src/integrationtest/python/issue_23_tests.py b/src/integrationtest/python/issue_23_tests.py index 755680f..04ff417 100644 --- a/src/integrationtest/python/issue_23_tests.py +++ b/src/integrationtest/python/issue_23_tests.py @@ -29,7 +29,7 @@ def test_issue_23(self): test_dir = Path(__file__).parent / "issue_23" for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[0], "1.10.6"), - (self.K8S_TEST_VERSIONS[-1], "1.20.0")): + (self.K8S_TEST_VERSIONS[-1], "1.22.0")): with self.subTest(k8s_version=k8s_version, istio_version=istio_version): os.environ["K8S_VERSION"] = k8s_version os.environ["ISTIO_VERSION"] = istio_version diff --git a/src/integrationtest/python/issue_52_tests.py b/src/integrationtest/python/issue_52_tests.py index 707a351..495c816 100644 --- a/src/integrationtest/python/issue_52_tests.py +++ b/src/integrationtest/python/issue_52_tests.py @@ -28,8 +28,8 @@ class Issue52Test(IntegrationTestSupport): def test_issue_52(self): test_dir = Path(__file__).parent / "issue_23" - for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[-2], "1.20.4"), - (self.K8S_TEST_VERSIONS[-1], "1.21.0")): + for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[-3], "1.20.4"), + (self.K8S_TEST_VERSIONS[-1], "1.22.0")): with self.subTest(k8s_version=k8s_version, istio_version=istio_version): os.environ["K8S_VERSION"] = k8s_version os.environ["ISTIO_VERSION"] = istio_version diff --git a/src/integrationtest/python/test_support.py b/src/integrationtest/python/test_support.py index 89142c7..78e5a31 100644 --- a/src/integrationtest/python/test_support.py +++ b/src/integrationtest/python/test_support.py @@ -34,8 +34,8 @@ class IntegrationTestSupport(unittest.TestCase): K8S_TEST_VERSIONS = ["1.20.15", "1.21.14", "1.22.17", "1.23.17", "1.24.17", "1.25.16", - "1.26.15", "1.27.13", "1.28.9", - "1.29.4"] + "1.26.15", "1.27.14", "1.28.10", + "1.29.5", "1.30.1"] def load_json_logs(self, log_file): decoder = json.JSONDecoder() diff --git a/src/main/python/kubernator/plugins/k8s.py b/src/main/python/kubernator/plugins/k8s.py index de8acb3..3e0544f 100644 --- a/src/main/python/kubernator/plugins/k8s.py +++ b/src/main/python/kubernator/plugins/k8s.py @@ -68,6 +68,19 @@ def final_resource_validator(resources: Sequence[K8SResource], resource, resource.source) +def normalize_pkg_version(v: str): + v_split = v.split(".") + rev = v_split[-1] + if not rev.isdigit(): + new_rev = "" + for c in rev: + if not c.isdigit(): + break + new_rev += c + v_split[-1] = new_rev + return tuple(map(int, v_split)) + + class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin): logger = logger @@ -193,7 +206,8 @@ def _setup_client(self): k8s.server_git_version = git_version logger.info("Found Kubernetes %s on %s", k8s.server_git_version, k8s.client.configuration.host) - K8SResource._k8s_client_version = tuple(map(int, pkg_version("kubernetes").split("."))) + + K8SResource._k8s_client_version = normalize_pkg_version(pkg_version("kubernetes")) K8SResource._k8s_field_validation = k8s.field_validation K8SResource._k8s_field_validation_patched = not k8s.disable_client_patches K8SResource._logger = self.logger diff --git a/src/unittest/python/issue64_tests.py b/src/unittest/python/issue64_tests.py new file mode 100644 index 0000000..b923abc --- /dev/null +++ b/src/unittest/python/issue64_tests.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Express Systems USA, Inc +# Copyright 2024 Karellen, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +from gevent.monkey import patch_all, is_anything_patched + +if not is_anything_patched(): + patch_all() + +import unittest +from kubernator.plugins.k8s import normalize_pkg_version + + +class Issue64Testcase(unittest.TestCase): + def test_issue64(self): + self.assertEqual((1, 2, 3), normalize_pkg_version("1.2.3")) + self.assertEqual((1, 2, 3), normalize_pkg_version("1.2.3a1"))