Normalize the salt caching API

https://github.com/saltstack/salt/pull/40429 changed the attribute used
in `salt/cache/__init__.py` without considering the usage of the cache
system elsewhere in the codebase. This led to a cascade of additional
changes to try to make everything work correctly.

This commit does 2 things:

1) Reverts the calls to the list function to use `list` instead of `ls`
   to conform with the established API used elsewhere in the codebase.

2) Modifies the cache modules so that they now use `list_` functions,
   aliased to `list` so that calls to cache loader instances' `*.list`
   functions elsewhere in the codebase will work.
This commit is contained in:
Erik Johnson 2017-08-17 14:04:30 -05:00
parent 973d288eca
commit ee59d127e8
4 changed files with 8 additions and 12 deletions

View File

@ -224,7 +224,7 @@ class Cache(object):
fun = '{0}.flush'.format(self.driver)
return self.modules[fun](bank, key=key, **self._kwargs)
def ls(self, bank):
def list(self, bank):
'''
Lists entries stored in the specified bank.
@ -240,11 +240,9 @@ class Cache(object):
Raises an exception if cache driver detected an error accessing data
in the cache backend (auth, permissions, etc).
'''
fun = '{0}.ls'.format(self.driver)
fun = '{0}.list'.format(self.driver)
return self.modules[fun](bank, **self._kwargs)
list = ls
def contains(self, bank, key=None):
'''
Checks if the specified bank contains the specified key.

View File

@ -61,7 +61,7 @@ api = None
# Define the module's virtual name
__virtualname__ = 'consul'
__func_alias__ = {'list': 'ls'}
__func_alias__ = {'list_': 'list'}
def __virtual__():
@ -139,7 +139,7 @@ def flush(bank, key=None):
)
def ls(bank):
def list_(bank):
'''
Return an iterable object containing all entries stored in the specified bank.
'''

View File

@ -23,7 +23,7 @@ import salt.utils.atomicfile
log = logging.getLogger(__name__)
__func_alias__ = {'list': 'ls'}
__func_alias__ = {'list_': 'list'}
def __cachedir(kwargs=None):
@ -143,7 +143,7 @@ def flush(bank, key=None, cachedir=None):
return True
def ls(bank, cachedir):
def list_(bank, cachedir):
'''
Return an iterable object containing all entries stored in the specified bank.
'''

View File

@ -114,9 +114,7 @@ from salt.exceptions import SaltCacheError
# -----------------------------------------------------------------------------
__virtualname__ = 'redis'
__func_alias__ = {
'ls': 'list'
}
__func_alias__ = {'list_': 'list'}
log = logging.getLogger(__file__)
@ -418,7 +416,7 @@ def flush(bank, key=None):
return True
def ls(bank):
def list_(bank):
'''
Lists entries stored in the specified bank.
'''