Skip to content

Commit

Permalink
sanity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
markuman committed Oct 31, 2022
1 parent 8c5d15f commit d45b83a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ remove: ## remove collection localy
rm -rf markuman* ~/.ansible/collections/ansible_collections/markuman/nextcloud

sanity: ## sanity checks
ansible-test sanity --python 3.8 --docker default
ansible-test sanity --python 3.10 --docker default

syntax: ## test compile
python -m py_compile plugins/lookup/*.py
Expand All @@ -38,4 +38,4 @@ round: ## short round
$(MAKE) install

test: ## run integration tests
$(MAKE) integration -C tests/integration/targets
$(MAKE) integration -C tests/integration/targets
17 changes: 12 additions & 5 deletions plugins/modules/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.markuman.nextcloud.plugins.module_utils.nextcloud import NextcloudHandler
from ansible_collections.markuman.nextcloud.plugins.module_utils.nextcloud import parameter_spects
import yaml
import copy
import traceback

try:
import yaml
HAS_YAML_LIB = True
except ImportError:
HAS_YAML_LIB = False
IMPORT_ERROR = traceback.format_exc()


def diff_handler(state_data, state):
new_state = copy.deepcopy(state_data)
Expand All @@ -54,6 +62,7 @@ def diff_handler(state_data, state):
after=yaml.safe_dump(new_state)
)


def main():
module = AnsibleModule(
supports_check_mode=True,
Expand All @@ -77,13 +86,11 @@ def main():

if not module.check_mode:
r, change = nc.put("ocs/v2.php/cloud/users/{USER}/{STATE}".format(USER=username, STATE=state))

retval, diff = diff_handler(current_state, state)
module.exit_json(changed=change, diff=diff, user_data=retval)
else:
module.exit_json(changed=change, diff={'before':{},'after':{}}, user_data={})


module.exit_json(changed=change, diff={'before': {}, 'after': {}}, user_data={})


if __name__ == '__main__':
Expand Down

0 comments on commit d45b83a

Please sign in to comment.