Merge "remove support of old plugin config format"

This commit is contained in:
Zuul 2019-06-26 14:19:34 +00:00 committed by Gerrit Code Review
commit 5d15fe7631
4 changed files with 3 additions and 46 deletions

View File

@ -360,18 +360,5 @@ class JJBConfig(object):
return result
def get_plugin_config(self, plugin, key, default=None):
value = self.get_module_config('plugin "{}"'.format(plugin), key,
default)
# Backwards compatibility for users who have not switched to the new
# plugin configuration format in their config. This code should be
# removed in future versions of JJB after 2.0.
if value is default:
old_value = self.get_module_config(plugin, key, _NOTSET)
# only log warning if detected a plugin config setting.
if old_value is not _NOTSET:
value = old_value
logger.warning(
DEPRECATED_PLUGIN_CONFIG_SECTION_MESSAGE.format(
plugin=plugin))
return value
return self.get_module_config('plugin "{}"'.format(plugin), key,
default)

View File

@ -1,5 +1,2 @@
[old_plugin]
setting = some value
[plugin "new_plugin"]
setting = some value

View File

@ -77,33 +77,6 @@ class TestConfigs(CmdTestsBase):
jenkins_jobs = entry.JenkinsJobs(args)
self.assertRaises(IOError, jenkins_jobs.execute)
def test_config_old_plugin_format_warning(self):
"""
Run test mode and check that old plugin settings result
in a warning, while ensuring that missing sections do not
trigger the same warning if a default value is provided.
"""
args = ['--conf',
os.path.join(self.fixtures_path, 'plugin_warning.ini'),
'test', 'foo']
jenkins_jobs = entry.JenkinsJobs(args)
jenkins_jobs.jjb_config.get_plugin_config(
'old_plugin', 'setting', True)
jenkins_jobs.jjb_config.get_plugin_config(
'old_plugin_no_conf', 'setting', True)
jenkins_jobs.jjb_config.get_plugin_config(
'new_plugin', 'setting')
self.assertIn(
'using a [old_plugin] section in your config file is deprecated',
self.logger.output)
self.assertNotIn(
'using a [old_plugin_no_conf] secton in your config file is '
'deprecated',
self.logger.output)
self.assertNotIn(
'using a [new_plugin] section in your config file is deprecated',
self.logger.output)
def test_config_options_not_replaced_by_cli_defaults(self):
"""
Run test mode and check config settings from conf file retained

View File

@ -1,3 +1,3 @@
[stash]
[plugin "stash"]
username=user
password=pass