Merge "Make v prefix optional when specifying to-version"

This commit is contained in:
Zuul
2025-07-14 18:32:11 +00:00
committed by Gerrit Code Review
2 changed files with 32 additions and 7 deletions

View File

@@ -35,6 +35,9 @@ class KubernetesStrategyValidator(StrategyValidationBase):
:param payload: strategy request payload
"""
return {
consts.EXTRA_ARGS_TO_VERSION: payload.get(consts.EXTRA_ARGS_TO_VERSION),
}
to_version = payload.get(consts.EXTRA_ARGS_TO_VERSION)
if to_version and not to_version.startswith("v"):
to_version = f"v{to_version}"
return {consts.EXTRA_ARGS_TO_VERSION: to_version}

View File

@@ -42,7 +42,29 @@ class TestKubernetesValidator(
def _get_validator(self):
return self.validator
def _get_build_extra_args_payload(self):
return {
consts.EXTRA_ARGS_TO_VERSION: "22.09",
}
def _get_build_extra_args_payload(self, version="v1.32.2"):
return {consts.EXTRA_ARGS_TO_VERSION: version}
def _get_expected_extra_args(self):
return {consts.EXTRA_ARGS_TO_VERSION: "v1.32.2"}
def test_build_extra_args_succeeds_without_v_prefix(self):
"""Test build_extra_args succeeds without v prefix
When the v prefix is not specified for a kube version, it should be
automatically included.
"""
payload = self._get_build_extra_args_payload("1.32.2")
expected_extra_args = self._get_expected_extra_args()
extra_args = self._get_validator().build_extra_args(payload)
if payload and not expected_extra_args:
expected_extra_args = payload
if expected_extra_args:
for key, value in expected_extra_args.items():
self.assertEqual(extra_args[key], value)
else:
self.assertIsNone(extra_args)