mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
salt.runners.cache: Add ability to clear checkout locks
This commit is contained in:
parent
8e086099f5
commit
3d7796d5dd
1 changed files with 23 additions and 8 deletions
|
@ -238,7 +238,7 @@ def clear_all(tgt=None, expr_form='glob'):
|
|||
clear_mine_flag=True)
|
||||
|
||||
|
||||
def clear_git_lock(role, remote=None):
|
||||
def clear_git_lock(role, remote=None, **kwargs):
|
||||
'''
|
||||
.. versionadded:: 2015.8.2
|
||||
|
||||
|
@ -261,12 +261,23 @@ def clear_git_lock(role, remote=None):
|
|||
have their lock cleared. For example, a ``remote`` value of **github**
|
||||
will remove the lock from all github.com remotes.
|
||||
|
||||
type : update,checkout
|
||||
The types of lock to clear. Can be ``update``, ``checkout``, or both of
|
||||
et (either comma-separated or as a Python list).
|
||||
|
||||
.. versionadded:: 2015.8.9
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-run cache.clear_git_lock git_pillar
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
type_ = salt.utils.split_input(kwargs.pop('type', ['update', 'checkout']))
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
if role == 'gitfs':
|
||||
git_objects = [salt.utils.gitfs.GitFS(__opts__)]
|
||||
git_objects[0].init_remotes(__opts__['gitfs_remotes'],
|
||||
|
@ -315,11 +326,15 @@ def clear_git_lock(role, remote=None):
|
|||
|
||||
ret = {}
|
||||
for obj in git_objects:
|
||||
cleared, errors = _clear_lock(obj.clear_lock, role, remote)
|
||||
if cleared:
|
||||
ret.setdefault('cleared', []).extend(cleared)
|
||||
if errors:
|
||||
ret.setdefault('errors', []).extend(errors)
|
||||
for lock_type in type_:
|
||||
cleared, errors = _clear_lock(obj.clear_lock,
|
||||
role,
|
||||
remote=remote,
|
||||
lock_type=lock_type)
|
||||
if cleared:
|
||||
ret.setdefault('cleared', []).extend(cleared)
|
||||
if errors:
|
||||
ret.setdefault('errors', []).extend(errors)
|
||||
if not ret:
|
||||
ret = 'No locks were removed'
|
||||
salt.output.display_output(ret, 'nested', opts=__opts__)
|
||||
return 'No locks were removed'
|
||||
return ret
|
||||
|
|
Loading…
Add table
Reference in a new issue