1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 10:51:13 +01:00

PluginCache: Check plugin name before trying to iteritems

Currently if your config contains

typo_for_a_global_alias: 1

You will get an error where we try to call 'iteritems' on the value 1. This
commit re-orders the checks so that you instead get an error for the
unrecognised 'typo_for_a_global_alias'.
This commit is contained in:
Brendan Jackman 2017-10-04 11:11:55 +01:00
parent 8daae0752e
commit 43f5cd793a

View File

@ -73,10 +73,7 @@ class PluginCache(object):
if self.is_global_alias(plugin_name): if self.is_global_alias(plugin_name):
self.add_global_alias(plugin_name, values, source) self.add_global_alias(plugin_name, values, source)
return return
for name, value in values.iteritems():
self.add_config(plugin_name, name, value, source)
def add_config(self, plugin_name, name, value, source):
if source not in self.sources: if source not in self.sources:
msg = "Source '{}' has not been added to the plugin cache." msg = "Source '{}' has not been added to the plugin cache."
raise RuntimeError(msg.format(source)) raise RuntimeError(msg.format(source))
@ -86,12 +83,13 @@ class PluginCache(object):
msg = 'configuration provided for unknown plugin "{}"' msg = 'configuration provided for unknown plugin "{}"'
raise ConfigError(msg.format(plugin_name)) raise ConfigError(msg.format(plugin_name))
if (plugin_name not in GENERIC_CONFIGS and for name, value in values.iteritems():
name not in self.get_plugin_parameters(plugin_name)): if (plugin_name not in GENERIC_CONFIGS and
msg = "'{}' is not a valid parameter for '{}'" name not in self.get_plugin_parameters(plugin_name)):
raise ConfigError(msg.format(name, plugin_name)) msg = "'{}' is not a valid parameter for '{}'"
raise ConfigError(msg.format(name, plugin_name))
self.plugin_configs[plugin_name][source][name] = value self.plugin_configs[plugin_name][source][name] = value
def is_global_alias(self, name): def is_global_alias(self, name):
return name in self._list_of_global_aliases return name in self._list_of_global_aliases