mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #47710 from terminalmage/fix-loader-whitelist
salt.loader: add error logging when whitelist lookup fails
This commit is contained in:
commit
22807ac756
4 changed files with 8 additions and 13 deletions
|
@ -1629,7 +1629,11 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
return True
|
||||
# if the modulename isn't in the whitelist, don't bother
|
||||
if self.whitelist and mod_name not in self.whitelist:
|
||||
raise KeyError
|
||||
log.error(
|
||||
'Failed to load function %s because its module (%s) is '
|
||||
'not in the whitelist: %s', key, mod_name, self.whitelist
|
||||
)
|
||||
raise KeyError(key)
|
||||
|
||||
def _inner_load(mod_name):
|
||||
for name in self._iter_files(mod_name):
|
||||
|
|
|
@ -45,11 +45,8 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin):
|
|||
def setup_loader_modules(self):
|
||||
utils = salt.loader.utils(
|
||||
salt.config.DEFAULT_MINION_OPTS,
|
||||
whitelist=['state']
|
||||
whitelist=['args', 'docker', 'json', 'state', 'thin']
|
||||
)
|
||||
# Force the LazyDict to populate its references. Otherwise the lookup
|
||||
# will fail inside the unit tests.
|
||||
list(utils)
|
||||
return {docker_mod: {'__context__': {'docker.docker_version': ''},
|
||||
'__utils__': utils}}
|
||||
|
||||
|
|
|
@ -26,12 +26,9 @@ class BotoCloudfrontTestCase(TestCase, LoaderModuleMockMixin):
|
|||
def setup_loader_modules(self):
|
||||
utils = salt.loader.utils(
|
||||
self.opts,
|
||||
whitelist=['boto3', 'dictdiffer', 'yamldumper'],
|
||||
whitelist=['boto3', 'dictdiffer', 'yaml'],
|
||||
context={},
|
||||
)
|
||||
# Force the LazyDict to populate its references. Otherwise the lookup
|
||||
# will fail inside the unit tests.
|
||||
list(utils)
|
||||
return {
|
||||
boto_cloudfront: {
|
||||
'__utils__': utils,
|
||||
|
|
|
@ -25,12 +25,9 @@ class BotoSqsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
def setup_loader_modules(self):
|
||||
utils = salt.loader.utils(
|
||||
self.opts,
|
||||
whitelist=['boto3', 'yamldumper'],
|
||||
whitelist=['boto3', 'yaml'],
|
||||
context={}
|
||||
)
|
||||
# Force the LazyDict to populate its references. Otherwise the lookup
|
||||
# will fail inside the unit tests.
|
||||
list(utils)
|
||||
return {
|
||||
boto_sqs: {
|
||||
'__utils__': utils,
|
||||
|
|
Loading…
Add table
Reference in a new issue