mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fix bug in github.absent state which can cause some users to not be removed from an organization.
This commit is contained in:
parent
38a67d7648
commit
a4597770c1
@ -123,29 +123,30 @@ def absent(name, profile="github", **kwargs):
|
||||
|
||||
target = __salt__['github.get_user'](name, profile=profile, **kwargs)
|
||||
|
||||
if not target:
|
||||
if target:
|
||||
if isinstance(target, bool) or target.get('in_org', False):
|
||||
if __opts__['test']:
|
||||
ret['comment'] = "User {0} will be deleted".format(name)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
|
||||
result = __salt__['github.remove_user'](name, profile=profile, **kwargs)
|
||||
|
||||
if result:
|
||||
ret['comment'] = 'Deleted user {0}'.format(name)
|
||||
ret['changes'].setdefault('old', 'User {0} exists'.format(name))
|
||||
ret['changes'].setdefault('new', 'User {0} deleted'.format(name))
|
||||
ret['result'] = True
|
||||
else:
|
||||
ret['comment'] = 'Failed to delete {0}'.format(name)
|
||||
ret['result'] = False
|
||||
else:
|
||||
ret['comment'] = "User {0} has already been deleted!".format(name)
|
||||
ret['result'] = True
|
||||
else:
|
||||
ret['comment'] = 'User {0} does not exist'.format(name)
|
||||
ret['result'] = True
|
||||
return ret
|
||||
elif isinstance(target, bool) and target:
|
||||
if __opts__['test']:
|
||||
ret['comment'] = "User {0} will be deleted".format(name)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
|
||||
result = __salt__['github.remove_user'](name, profile=profile, **kwargs)
|
||||
|
||||
if result:
|
||||
ret['comment'] = 'Deleted user {0}'.format(name)
|
||||
ret['changes'].setdefault('old', 'User {0} exists'.format(name))
|
||||
ret['changes'].setdefault('new', 'User {0} deleted'.format(name))
|
||||
ret['result'] = True
|
||||
else:
|
||||
ret['comment'] = 'Failed to delete {0}'.format(name)
|
||||
ret['result'] = False
|
||||
else:
|
||||
ret['comment'] = "User {0} has already been deleted!".format(name)
|
||||
ret['result'] = True
|
||||
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user