mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 20:08:41 +00:00
Remove 'debug' parameter from new CLI modules. Move log writing to single function. (#740)
This commit is contained in:
parent
7aa9791ea6
commit
762ce3e1cf
@ -368,11 +368,11 @@ options:
|
|||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
aliases: [ tls_verify ]
|
aliases: [ tls_verify ]
|
||||||
debug:
|
# debug:
|
||||||
description:
|
# description:
|
||||||
- Debug mode
|
# - Debug mode
|
||||||
type: bool
|
# type: bool
|
||||||
default: false
|
# default: false
|
||||||
cli_context:
|
cli_context:
|
||||||
description:
|
description:
|
||||||
- The Docker CLI context to use.
|
- The Docker CLI context to use.
|
||||||
|
|||||||
@ -260,12 +260,8 @@ class AnsibleDockerClientBase(Client):
|
|||||||
def log(self, msg, pretty_print=False):
|
def log(self, msg, pretty_print=False):
|
||||||
pass
|
pass
|
||||||
# if self.debug:
|
# if self.debug:
|
||||||
# log_file = open('docker.log', 'a')
|
# from .util import log_debug
|
||||||
# if pretty_print:
|
# log_debug(msg, pretty_print=pretty_print)
|
||||||
# log_file.write(json.dumps(msg, sort_keys=True, indent=4, separators=(',', ': ')))
|
|
||||||
# log_file.write(u'\n')
|
|
||||||
# else:
|
|
||||||
# log_file.write(msg + u'\n')
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def fail(self, msg, **kwargs):
|
def fail(self, msg, **kwargs):
|
||||||
|
|||||||
@ -131,12 +131,8 @@ class AnsibleDockerClientBase(Client):
|
|||||||
def log(self, msg, pretty_print=False):
|
def log(self, msg, pretty_print=False):
|
||||||
pass
|
pass
|
||||||
# if self.debug:
|
# if self.debug:
|
||||||
# log_file = open('docker.log', 'a')
|
# from .util import log_debug
|
||||||
# if pretty_print:
|
# log_debug(msg, pretty_print=pretty_print)
|
||||||
# log_file.write(json.dumps(msg, sort_keys=True, indent=4, separators=(',', ': ')))
|
|
||||||
# log_file.write(u'\n')
|
|
||||||
# else:
|
|
||||||
# log_file.write(msg + u'\n')
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def fail(self, msg, **kwargs):
|
def fail(self, msg, **kwargs):
|
||||||
|
|||||||
@ -38,7 +38,7 @@ DOCKER_COMMON_ARGS = dict(
|
|||||||
client_key=dict(type='path', aliases=['tls_client_key', 'key_path']),
|
client_key=dict(type='path', aliases=['tls_client_key', 'key_path']),
|
||||||
tls=dict(type='bool', default=DEFAULT_TLS, fallback=(env_fallback, ['DOCKER_TLS'])),
|
tls=dict(type='bool', default=DEFAULT_TLS, fallback=(env_fallback, ['DOCKER_TLS'])),
|
||||||
validate_certs=dict(type='bool', default=DEFAULT_TLS_VERIFY, fallback=(env_fallback, ['DOCKER_TLS_VERIFY']), aliases=['tls_verify']),
|
validate_certs=dict(type='bool', default=DEFAULT_TLS_VERIFY, fallback=(env_fallback, ['DOCKER_TLS_VERIFY']), aliases=['tls_verify']),
|
||||||
debug=dict(type='bool', default=False),
|
# debug=dict(type='bool', default=False),
|
||||||
cli_context=dict(type='str'),
|
cli_context=dict(type='str'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -89,12 +89,8 @@ class AnsibleDockerClientBase(object):
|
|||||||
def log(self, msg, pretty_print=False):
|
def log(self, msg, pretty_print=False):
|
||||||
pass
|
pass
|
||||||
# if self.debug:
|
# if self.debug:
|
||||||
# log_file = open('docker.log', 'a')
|
# from .util import log_debug
|
||||||
# if pretty_print:
|
# log_debug(msg, pretty_print=pretty_print)
|
||||||
# log_file.write(json.dumps(msg, sort_keys=True, indent=4, separators=(',', ': ')))
|
|
||||||
# log_file.write(u'\n')
|
|
||||||
# else:
|
|
||||||
# log_file.write(msg + u'\n')
|
|
||||||
|
|
||||||
def get_cli(self):
|
def get_cli(self):
|
||||||
return self._cli
|
return self._cli
|
||||||
@ -299,7 +295,7 @@ class AnsibleModuleDockerClient(AnsibleDockerClientBase):
|
|||||||
required_by=required_by or {},
|
required_by=required_by or {},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.debug = self.module.params['debug']
|
self.debug = False # self.module.params['debug']
|
||||||
self.check_mode = self.module.check_mode
|
self.check_mode = self.module.check_mode
|
||||||
self.diff = self.module._diff
|
self.diff = self.module._diff
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from __future__ import (absolute_import, division, print_function)
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@ -85,6 +86,19 @@ def sanitize_result(data):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def log_debug(msg, pretty_print=False):
|
||||||
|
"""Write a log message to docker.log.
|
||||||
|
|
||||||
|
If ``pretty_print=True``, the message will be pretty-printed as JSON.
|
||||||
|
"""
|
||||||
|
with open('docker.log', 'a') as log_file:
|
||||||
|
if pretty_print:
|
||||||
|
log_file.write(json.dumps(msg, sort_keys=True, indent=4, separators=(',', ': ')))
|
||||||
|
log_file.write(u'\n')
|
||||||
|
else:
|
||||||
|
log_file.write(msg + u'\n')
|
||||||
|
|
||||||
|
|
||||||
class DockerBaseClass(object):
|
class DockerBaseClass(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.debug = False
|
self.debug = False
|
||||||
@ -92,12 +106,7 @@ class DockerBaseClass(object):
|
|||||||
def log(self, msg, pretty_print=False):
|
def log(self, msg, pretty_print=False):
|
||||||
pass
|
pass
|
||||||
# if self.debug:
|
# if self.debug:
|
||||||
# log_file = open('docker.log', 'a')
|
# log_debug(msg, pretty_print=pretty_print)
|
||||||
# if pretty_print:
|
|
||||||
# log_file.write(json.dumps(msg, sort_keys=True, indent=4, separators=(',', ': ')))
|
|
||||||
# log_file.write(u'\n')
|
|
||||||
# else:
|
|
||||||
# log_file.write(msg + u'\n')
|
|
||||||
|
|
||||||
|
|
||||||
def update_tls_hostname(result, old_behavior=False, deprecate_function=None, uses_tls=True):
|
def update_tls_hostname(result, old_behavior=False, deprecate_function=None, uses_tls=True):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user