mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-23 10:42:14 +01:00
conf: Change how api_host_options determine option types
The _integer_opts and _boolean_opts specify option types for both global options as well as api_host_options
This commit is contained in:
parent
b0078c5d2e
commit
2a9edeec5b
20
osc/conf.py
20
osc/conf.py
@ -189,13 +189,15 @@ if not os.path.isfile('/usr/lib/build/vc') and os.path.isfile('/usr/lib/obs-buil
|
|||||||
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj',
|
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj',
|
||||||
'downloadurl', 'sshkey']
|
'downloadurl', 'sshkey']
|
||||||
|
|
||||||
|
|
||||||
|
# _integer_opts and _boolean_opts specify option types for both global options as well as api_host_options
|
||||||
_integer_opts = ('build-jobs',)
|
_integer_opts = ('build-jobs',)
|
||||||
_boolean_opts = (
|
_boolean_opts = (
|
||||||
'debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist',
|
'debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist',
|
||||||
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
|
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
|
||||||
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'no_verify', 'builtin_signature_check',
|
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'no_verify', 'builtin_signature_check',
|
||||||
'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage',
|
'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage',
|
||||||
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail')
|
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail', 'allow_http', 'sslcertck', )
|
||||||
|
|
||||||
|
|
||||||
def apply_option_types(config, conffile=""):
|
def apply_option_types(config, conffile=""):
|
||||||
@ -211,6 +213,8 @@ def apply_option_types(config, conffile=""):
|
|||||||
typed_opts = ((_boolean_opts, cp.getboolean), (_integer_opts, cp.getint))
|
typed_opts = ((_boolean_opts, cp.getboolean), (_integer_opts, cp.getint))
|
||||||
for opts, meth in typed_opts:
|
for opts, meth in typed_opts:
|
||||||
for opt in opts:
|
for opt in opts:
|
||||||
|
if opt not in config:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
config[opt] = meth('general', opt)
|
config[opt] = meth('general', opt)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -826,11 +830,15 @@ def get_config(override_conffile=None,
|
|||||||
credentials.AbstractCredentialsManager.config_entry,
|
credentials.AbstractCredentialsManager.config_entry,
|
||||||
)
|
)
|
||||||
for key in optional:
|
for key in optional:
|
||||||
if cp.has_option(url, key):
|
if not cp.has_option(url, key):
|
||||||
if key in ('sslcertck', 'allow_http'):
|
continue
|
||||||
api_host_options[apiurl][key] = cp.getboolean(url, key)
|
if key in _boolean_opts:
|
||||||
else:
|
api_host_options[apiurl][key] = cp.getboolean(url, key)
|
||||||
api_host_options[apiurl][key] = cp.get(url, key)
|
elif key in _integer_opts:
|
||||||
|
api_host_options[apiurl][key] = cp.getint(url, key)
|
||||||
|
else:
|
||||||
|
api_host_options[apiurl][key] = cp.get(url, key)
|
||||||
|
|
||||||
if cp.has_option(url, 'build-root', proper=True):
|
if cp.has_option(url, 'build-root', proper=True):
|
||||||
api_host_options[apiurl]['build-root'] = cp.get(url, 'build-root', raw=True)
|
api_host_options[apiurl]['build-root'] = cp.get(url, 'build-root', raw=True)
|
||||||
|
|
||||||
|
@ -16,23 +16,31 @@ class TestConf(unittest.TestCase):
|
|||||||
def test_bool_opts_defaults(self):
|
def test_bool_opts_defaults(self):
|
||||||
config = osc.conf.config
|
config = osc.conf.config
|
||||||
for opt in osc.conf._boolean_opts:
|
for opt in osc.conf._boolean_opts:
|
||||||
|
if opt not in config:
|
||||||
|
continue
|
||||||
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
def test_int_opts_defaults(self):
|
def test_int_opts_defaults(self):
|
||||||
config = osc.conf.config
|
config = osc.conf.config
|
||||||
for opt in osc.conf._integer_opts:
|
for opt in osc.conf._integer_opts:
|
||||||
|
if opt not in config:
|
||||||
|
continue
|
||||||
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
def test_bool_opts(self):
|
def test_bool_opts(self):
|
||||||
osc.conf.get_config()
|
osc.conf.get_config()
|
||||||
config = osc.conf.config
|
config = osc.conf.config
|
||||||
for opt in osc.conf._boolean_opts:
|
for opt in osc.conf._boolean_opts:
|
||||||
|
if opt not in config:
|
||||||
|
continue
|
||||||
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
def test_int_opts(self):
|
def test_int_opts(self):
|
||||||
osc.conf.get_config()
|
osc.conf.get_config()
|
||||||
config = osc.conf.config
|
config = osc.conf.config
|
||||||
for opt in osc.conf._integer_opts:
|
for opt in osc.conf._integer_opts:
|
||||||
|
if opt not in config:
|
||||||
|
continue
|
||||||
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user