Review requests

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
pull/82246/head
Abhijeet Kasurde 2 weeks ago
parent b43648a124
commit b50a3ed86b

@ -705,6 +705,17 @@ class ConfigManager:
else:
raise AnsibleUndefinedConfigEntry(f'No config definition exists for {_get_config_label(plugin_type, plugin_name, config)}.')
if config == "GALAXY_RETRY_HTTP_ERROR_CODES":
try:
for i in range(0, len(value)):
http_error_code = int(value[i])
if http_error_code < 100 or http_error_code > 999:
raise ValueError(f"{http_error_code} must be between 100-999")
value[i] = http_error_code
except ValueError:
raise AnsibleOptionsError(f'Invalid value {value!r} for config {_get_config_label(plugin_type, plugin_name, config)}.',
help_text='Valid values are 3-digit numbers.')
if not _tags.Origin.is_tagged_on(value):
value = _tags.Origin(description=f'<Config {origin}>').tag(value)

@ -300,3 +300,20 @@ def test_config_trust_from_file(tmp_path: pathlib.Path) -> None:
assert origin
assert origin.path == str(cfg_path)
assert origin.description == "section 'testing' option 'valid'"
def test_galaxy_retry_http_error_codes(tmp_path: pathlib.Path) -> None:
cfg_path = tmp_path / 'test.cfg'
cfg_path.write_text("[galaxy]\nretry_http_error_codes=429,502,520")
manager = ConfigManager(str(cfg_path))
result = manager.get_config_value("GALAXY_RETRY_HTTP_ERROR_CODES")
assert result == [429, 502, 520]
def test_galaxy_retry_http_error_codes_invalid(tmp_path: pathlib.Path) -> None:
cfg_path = tmp_path / 'test.cfg'
cfg_path.write_text("[galaxy]\nretry_http_error_codes=429,502,520,invalid")
manager = ConfigManager(str(cfg_path))
with pytest.raises(AnsibleOptionsError) as exec_info:
manager.get_config_value("GALAXY_RETRY_HTTP_ERROR_CODES")
assert "Invalid value [429, 502, 520, 'invalid'] for config" in str(exec_info.value)

Loading…
Cancel
Save