Refactoring
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

- unix_socket still wasn't used correctly
This commit is contained in:
Peter Šurda 2024-04-22 15:26:49 +08:00
parent b6ec505285
commit fb178b36cd
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

View File

@ -121,11 +121,12 @@ def get_key_from_filesystem(module):
# Fetch Syncthing configuration
def remote_config(module, method='GET', config=None, result=None, device=None):
unix_socket = None
if 'unix_socket' in module.params:
unix_socket = module.params['unix_socket']
url, headers = make_headers(
host=module.params['host'],
unix_socket=module.params['unix_socket']
if 'unix_socket' in module.params
else None,
unix_socket=unix_socket,
api_key= module.params['api_key'],
device=device)
data = config
@ -135,14 +136,10 @@ def remote_config(module, method='GET', config=None, result=None, device=None):
if not result:
result = {}
if 'unix_socket' in module.params:
resp, info = fetch_url(
module, unix_socket=url, data=data, headers=headers,
method=method, timeout=module.params['timeout'])
else:
resp, info = fetch_url(
module, url, data=data, headers=headers,
method=method, timeout=module.params['timeout'])
resp, info = fetch_url(
module, url=url, unix_socket=unix_socket,
data=data, headers=headers,
method=method, timeout=module.params['timeout'])
if not info or info['status'] != 200:
result['response'] = info