Use JJBConfig in ModuleRegistry.
Remove reference to ConfigParser object in ModuleRegistry. Instead: * make use of JJBConfig.get_module_config to grab settings for Hipchat Notifier Plugin * make use of JJBConfig.yamlparser['allow_empty_variables'] rather than repeating ConfigParser logic moved out of the YamlParser into JJBConfig in an earlier commit. Change-Id: Icb7ef514826005545e48af993335ce120f973b0d
This commit is contained in:
parent
4f04de1f9a
commit
0da11b51c5
@ -100,10 +100,11 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
|||||||
This is done lazily to avoid looking up the '[hipchat]' section
|
This is done lazily to avoid looking up the '[hipchat]' section
|
||||||
unless actually required.
|
unless actually required.
|
||||||
"""
|
"""
|
||||||
|
jjb_config = self.registry.jjb_config
|
||||||
if(not self.authToken):
|
if(not self.authToken):
|
||||||
try:
|
try:
|
||||||
self.authToken = self.registry.global_config.get(
|
self.authToken = jjb_config.get_module_config('hipchat',
|
||||||
'hipchat', 'authtoken')
|
'authtoken')
|
||||||
# Require that the authtoken is non-null
|
# Require that the authtoken is non-null
|
||||||
if self.authToken == '':
|
if self.authToken == '':
|
||||||
raise jenkins_jobs.errors.JenkinsJobsException(
|
raise jenkins_jobs.errors.JenkinsJobsException(
|
||||||
@ -113,8 +114,8 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
|||||||
logger.fatal("The configuration file needs a hipchat section" +
|
logger.fatal("The configuration file needs a hipchat section" +
|
||||||
" containing authtoken:\n{0}".format(e))
|
" containing authtoken:\n{0}".format(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
self.jenkinsUrl = self.registry.global_config.get('jenkins', 'url')
|
self.jenkinsUrl = jjb_config.jenkins['url']
|
||||||
self.sendAs = self.registry.global_config.get('hipchat', 'send-as')
|
self.sendAs = jjb_config.get_module_config('hipchat', 'send-as')
|
||||||
|
|
||||||
def gen_xml(self, parser, xml_parent, data):
|
def gen_xml(self, parser, xml_parent, data):
|
||||||
hipchat = data.get('hipchat')
|
hipchat = data.get('hipchat')
|
||||||
|
@ -79,7 +79,7 @@ class YamlParser(object):
|
|||||||
self.keep_desc = jjb_config.yamlparser['keep_descriptions']
|
self.keep_desc = jjb_config.yamlparser['keep_descriptions']
|
||||||
self.path = jjb_config.yamlparser['include_path']
|
self.path = jjb_config.yamlparser['include_path']
|
||||||
|
|
||||||
self.registry = ModuleRegistry(jjb_config.config_parser,
|
self.registry = ModuleRegistry(jjb_config,
|
||||||
plugins_info)
|
plugins_info)
|
||||||
|
|
||||||
def parse_fp(self, fp):
|
def parse_fp(self, fp):
|
||||||
|
@ -30,11 +30,11 @@ logger = logging.getLogger(__name__)
|
|||||||
class ModuleRegistry(object):
|
class ModuleRegistry(object):
|
||||||
entry_points_cache = {}
|
entry_points_cache = {}
|
||||||
|
|
||||||
def __init__(self, config, plugins_list=None):
|
def __init__(self, jjb_config, plugins_list=None):
|
||||||
self.modules = []
|
self.modules = []
|
||||||
self.modules_by_component_type = {}
|
self.modules_by_component_type = {}
|
||||||
self.handlers = {}
|
self.handlers = {}
|
||||||
self.global_config = config
|
self.jjb_config = jjb_config
|
||||||
self.masked_warned = {}
|
self.masked_warned = {}
|
||||||
|
|
||||||
if plugins_list is None:
|
if plugins_list is None:
|
||||||
@ -153,15 +153,9 @@ class ModuleRegistry(object):
|
|||||||
if template_data:
|
if template_data:
|
||||||
# Template data contains values that should be interpolated
|
# Template data contains values that should be interpolated
|
||||||
# into the component definition
|
# into the component definition
|
||||||
allow_empty_variables = self.global_config \
|
|
||||||
and self.global_config.has_section('job_builder') \
|
|
||||||
and self.global_config.has_option(
|
|
||||||
'job_builder', 'allow_empty_variables') \
|
|
||||||
and self.global_config.getboolean(
|
|
||||||
'job_builder', 'allow_empty_variables')
|
|
||||||
|
|
||||||
component_data = deep_format(
|
component_data = deep_format(
|
||||||
component_data, template_data, allow_empty_variables)
|
component_data, template_data,
|
||||||
|
self.jjb_config.yamlparser['allow_empty_variables'])
|
||||||
else:
|
else:
|
||||||
# The component is a simple string name, eg "run-tests"
|
# The component is a simple string name, eg "run-tests"
|
||||||
name = component
|
name = component
|
||||||
|
@ -34,7 +34,6 @@ class ModuleRegistryPluginInfoTestsWithScenarios(TestWithScenarios,
|
|||||||
|
|
||||||
jjb_config = JJBConfig()
|
jjb_config = JJBConfig()
|
||||||
jjb_config.validate()
|
jjb_config.validate()
|
||||||
config = jjb_config.config_parser
|
|
||||||
|
|
||||||
plugin_info = [{'shortName': "HerpDerpPlugin",
|
plugin_info = [{'shortName': "HerpDerpPlugin",
|
||||||
'longName': "Blah Blah Blah Plugin"
|
'longName': "Blah Blah Blah Plugin"
|
||||||
@ -45,7 +44,7 @@ class ModuleRegistryPluginInfoTestsWithScenarios(TestWithScenarios,
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.addDetail("plugin_info", text_content(str(plugin_info)))
|
self.addDetail("plugin_info", text_content(str(plugin_info)))
|
||||||
self.registry = ModuleRegistry(config, plugin_info)
|
self.registry = ModuleRegistry(jjb_config, plugin_info)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(ModuleRegistryPluginInfoTestsWithScenarios, self).tearDown()
|
super(ModuleRegistryPluginInfoTestsWithScenarios, self).tearDown()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user