Skip to content

Commit

Permalink
Merge pull request #47710 from terminalmage/fix-loader-whitelist
Browse files Browse the repository at this point in the history
salt.loader: add error logging when whitelist lookup fails
  • Loading branch information
Nicole Thomas committed May 18, 2018
2 parents b91c0f5 + 6192391 commit 22807ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
6 changes: 5 additions & 1 deletion salt/loader.py
Expand Up @@ -1629,7 +1629,11 @@ def _load(self, key):
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):
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/modules/test_dockermod.py
Expand Up @@ -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}}

Expand Down
5 changes: 1 addition & 4 deletions tests/unit/states/test_boto_cloudfront.py
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/states/test_boto_sqs.py
Expand Up @@ -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,
Expand Down

0 comments on commit 22807ac

Please sign in to comment.