Disentangle YamlParser and ModuleRegistry classes
Create the ModuleRegistry anywhere other than inside the YamlParser class. This will make it slightly easier to factor a XmlGenerator out of YamlParser, but I also want to work toward eliminating the circular references between YamlParser and ModuleRegistry which have been making it difficult to understand overall program flow. This commit also replaces all YamlParser instances being passed to Jenkins job config generating functions with a ModuleRegistry. Mostly it seems like the parser was only needed to call the ModuleRegistry's 'dispatch' method which to be honest I don't fully understand. This is where the circular references mentioned in previously come in...it seems like the "dispatch" function needs access to the (mostly) raw data contained by the parser, so it took that as a parameter. The need for the YamlParser's job data can be satisfied by assigning it to a property on the ModuleRegistry object before Yaml expansion or XML generation begins; by doing this, we allow the ModuleRegistry to avoid referencing the parser. Change-Id: I4b571299b81e708540392ad963163fe092acf1d9
This commit is contained in:
@@ -117,7 +117,7 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
self.jenkinsUrl = jjb_config.jenkins['url']
|
||||
self.sendAs = jjb_config.get_module_config('hipchat', 'send-as')
|
||||
|
||||
def gen_xml(self, parser, xml_parent, data):
|
||||
def gen_xml(self, xml_parent, data):
|
||||
hipchat = data.get('hipchat')
|
||||
if not hipchat or not hipchat.get('enabled', True):
|
||||
return
|
||||
@@ -144,8 +144,7 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
"'hipchat' module supports the old plugin versions <1.9, "
|
||||
"newer versions are supported via the 'publishers' module. "
|
||||
"Please upgrade you job definition")
|
||||
return self.registry.dispatch('publisher', parser, publishers,
|
||||
data)
|
||||
return self.registry.dispatch('publisher', publishers, data)
|
||||
else:
|
||||
properties = xml_parent.find('properties')
|
||||
if properties is None:
|
||||
|
||||
Reference in New Issue
Block a user