mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Improve language.
This commit is contained in:
@@ -276,7 +276,7 @@ class APIClient(
|
||||
return response.text
|
||||
|
||||
def _post_json(self, url, data, **kwargs):
|
||||
# Go <1.1 can't unserialize null to a string
|
||||
# Go <1.1 cannot unserialize null to a string
|
||||
# so we do this disgusting thing here.
|
||||
data2 = {}
|
||||
if data is not None and isinstance(data, dict):
|
||||
@@ -316,8 +316,8 @@ class APIClient(
|
||||
# close TLS sockets.
|
||||
sock._response = response
|
||||
except AttributeError:
|
||||
# UNIX sockets can't have attributes set on them, but that's
|
||||
# fine because we won't be doing TLS over them
|
||||
# UNIX sockets cannot have attributes set on them, but that's
|
||||
# fine because we will not be doing TLS over them
|
||||
pass
|
||||
|
||||
return sock
|
||||
@@ -340,7 +340,7 @@ class APIClient(
|
||||
data += reader.read(reader._fp.chunk_left)
|
||||
yield data
|
||||
else:
|
||||
# Response isn't chunked, meaning we probably
|
||||
# Response is not chunked, meaning we probably
|
||||
# encountered an error immediately
|
||||
yield self._result(response, json=decode)
|
||||
|
||||
@@ -419,7 +419,7 @@ class APIClient(
|
||||
response.close()
|
||||
|
||||
def _disable_socket_timeout(self, socket):
|
||||
""" Depending on the combination of python version and whether we're
|
||||
""" Depending on the combination of python version and whether we are
|
||||
connecting over http or https, we might need to access _sock, which
|
||||
may or may not exist; or we may need to just settimeout on socket
|
||||
itself, which also may or may not have settimeout on it. To avoid
|
||||
@@ -440,7 +440,7 @@ class APIClient(
|
||||
if hasattr(s, 'gettimeout'):
|
||||
timeout = s.gettimeout()
|
||||
|
||||
# Don't change the timeout if it is already disabled.
|
||||
# Do not change the timeout if it is already disabled.
|
||||
if timeout is None or timeout == 0.0:
|
||||
continue
|
||||
|
||||
@@ -456,7 +456,7 @@ class APIClient(
|
||||
|
||||
def _get_result_tty(self, stream, res, is_tty):
|
||||
# We should also use raw streaming (without keep-alive)
|
||||
# if we're dealing with a tty-enabled container.
|
||||
# if we are dealing with a tty-enabled container.
|
||||
if is_tty:
|
||||
return self._stream_raw_result(res) if stream else \
|
||||
self._result(res, binary=True)
|
||||
@@ -506,7 +506,7 @@ class APIClient(
|
||||
def _set_auth_headers(self, headers):
|
||||
log.debug('Looking for auth config')
|
||||
|
||||
# If we don't have any auth data so far, try reloading the config
|
||||
# If we do not have any auth data so far, try reloading the config
|
||||
# file one more time in case anything showed up in there.
|
||||
if not self._auth_configs or self._auth_configs.is_empty:
|
||||
log.debug("No auth config in memory - loading from filesystem")
|
||||
|
||||
@@ -72,7 +72,7 @@ class DaemonApiMixin(object):
|
||||
If the server returns an error.
|
||||
"""
|
||||
|
||||
# If we don't have any auth data so far, try reloading the config file
|
||||
# If we do not have any auth data so far, try reloading the config file
|
||||
# one more time in case anything showed up in there.
|
||||
# If dockercfg_path is passed check to see if the config file exists,
|
||||
# if so load that config.
|
||||
@@ -107,7 +107,7 @@ class DaemonApiMixin(object):
|
||||
def ping(self):
|
||||
"""
|
||||
Checks the server is responsive. An exception will be raised if it
|
||||
isn't responding.
|
||||
is not responding.
|
||||
|
||||
Returns:
|
||||
(bool) The response from the server.
|
||||
|
||||
@@ -170,7 +170,7 @@ class AuthConfig(dict):
|
||||
with open(config_file) as f:
|
||||
config_dict = json.load(f)
|
||||
except (IOError, KeyError, ValueError) as e:
|
||||
# Likely missing new Docker config file or it's in an
|
||||
# Likely missing new Docker config file or it is in an
|
||||
# unknown format, continue to attempt to read old location
|
||||
# and format.
|
||||
log.debug(e)
|
||||
@@ -194,7 +194,7 @@ class AuthConfig(dict):
|
||||
return cls(res, credstore_env)
|
||||
|
||||
log.debug(
|
||||
"Couldn't find auth-related section ; attempting to interpret "
|
||||
"Could not find auth-related section ; attempting to interpret "
|
||||
"as auth-only file"
|
||||
)
|
||||
return cls({'auths': cls.parse_auth(config_dict)}, credstore_env)
|
||||
|
||||
@@ -52,7 +52,7 @@ class APIError(_HTTPError, DockerException):
|
||||
"""
|
||||
def __init__(self, message, response=None, explanation=None):
|
||||
# requests 1.2 supports response as a keyword argument, but
|
||||
# requests 1.1 doesn't
|
||||
# requests 1.1 does not
|
||||
super(APIError, self).__init__(message)
|
||||
self.response = response
|
||||
self.explanation = explanation
|
||||
|
||||
@@ -106,7 +106,7 @@ class NpipeHTTPAdapter(BaseHTTPAdapter):
|
||||
|
||||
def request_url(self, request, proxies):
|
||||
# The select_proxy utility in requests errors out when the provided URL
|
||||
# doesn't have a hostname, like is the case when using a UNIX socket.
|
||||
# does not have a hostname, like is the case when using a UNIX socket.
|
||||
# Since proxies are an irrelevant notion in the case of UNIX sockets
|
||||
# anyway, we simply return the path URL directly.
|
||||
# See also: https://github.com/docker/docker-sdk-python/issues/811
|
||||
|
||||
@@ -107,7 +107,7 @@ class UnixHTTPAdapter(BaseHTTPAdapter):
|
||||
|
||||
def request_url(self, request, proxies):
|
||||
# The select_proxy utility in requests errors out when the provided URL
|
||||
# doesn't have a hostname, like is the case when using a UNIX socket.
|
||||
# does not have a hostname, like is the case when using a UNIX socket.
|
||||
# Since proxies are an irrelevant notion in the case of UNIX sockets
|
||||
# anyway, we simply return the path URL directly.
|
||||
# See also: https://github.com/docker/docker-py/issues/811
|
||||
|
||||
@@ -67,7 +67,7 @@ class CancellableStream(object):
|
||||
sock = sock_raw._sock
|
||||
|
||||
elif hasattr(sock_fp, 'channel'):
|
||||
# We're working with a paramiko (SSH) channel, which doesn't
|
||||
# We are working with a paramiko (SSH) channel, which does not
|
||||
# support cancelable streams with the current implementation
|
||||
raise DockerException(
|
||||
'Cancellable streams not supported for the SSH protocol'
|
||||
|
||||
@@ -100,7 +100,7 @@ def create_archive(root, files=None, fileobj=None, gzip=False,
|
||||
i.mtime = int(i.mtime)
|
||||
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
# Windows doesn't keep track of the execute bit, so we make files
|
||||
# Windows does not keep track of the execute bit, so we make files
|
||||
# and directories executable by default.
|
||||
i.mode = i.mode & 0o755 | 0o111
|
||||
|
||||
@@ -113,7 +113,7 @@ def create_archive(root, files=None, fileobj=None, gzip=False,
|
||||
'Can not read file in context: {0}'.format(full_path)
|
||||
)
|
||||
else:
|
||||
# Directories, FIFOs, symlinks... don't need to be read.
|
||||
# Directories, FIFOs, symlinks... do not need to be read.
|
||||
t.addfile(i, None)
|
||||
|
||||
for name, contents in extra_files:
|
||||
@@ -210,10 +210,10 @@ class PatternMatcher(object):
|
||||
continue
|
||||
|
||||
if match:
|
||||
# If we want to skip this file and it's a directory
|
||||
# If we want to skip this file and it is a directory
|
||||
# then we should first check to see if there's an
|
||||
# excludes pattern (e.g. !dir/file) that starts with this
|
||||
# dir. If so then we can't skip this dir.
|
||||
# dir. If so then we cannot skip this dir.
|
||||
skip = True
|
||||
|
||||
for pat in self.patterns:
|
||||
|
||||
@@ -70,7 +70,7 @@ def load_general_config(config_path=None):
|
||||
with open(config_file) as f:
|
||||
return json.load(f)
|
||||
except (IOError, ValueError) as e:
|
||||
# In the case of a legacy `.dockercfg` file, we won't
|
||||
# In the case of a legacy `.dockercfg` file, we will not
|
||||
# be able to load any JSON data.
|
||||
log.debug(e)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def fnmatch(name, pat):
|
||||
An initial period in FILENAME is not special.
|
||||
Both FILENAME and PATTERN are first case-normalized
|
||||
if the operating system requires it.
|
||||
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
|
||||
If you do not want this, use fnmatchcase(FILENAME, PATTERN).
|
||||
"""
|
||||
|
||||
name = name.lower()
|
||||
@@ -58,7 +58,7 @@ def fnmatch(name, pat):
|
||||
|
||||
def fnmatchcase(name, pat):
|
||||
"""Test whether FILENAME matches PATTERN, including case.
|
||||
This is a version of fnmatch() which doesn't case-normalize
|
||||
This is a version of fnmatch() which does not case-normalize
|
||||
its arguments.
|
||||
"""
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ def read(socket, n=4096):
|
||||
len(e.args) > 0 and
|
||||
e.args[0] == NPIPE_ENDED)
|
||||
if is_pipe_ended:
|
||||
# npipes don't support duplex sockets, so we interpret
|
||||
# npipes do not support duplex sockets, so we interpret
|
||||
# a PIPE_ENDED error as a close operation (0-length read).
|
||||
return ''
|
||||
raise
|
||||
@@ -73,7 +73,7 @@ def read(socket, n=4096):
|
||||
def read_exactly(socket, n):
|
||||
"""
|
||||
Reads exactly n bytes from socket
|
||||
Raises SocketError if there isn't enough data
|
||||
Raises SocketError if there is not enough data
|
||||
"""
|
||||
data = binary_type()
|
||||
while len(data) < n:
|
||||
|
||||
@@ -160,7 +160,7 @@ def convert_volume_binds(binds):
|
||||
mode = 'rw'
|
||||
|
||||
# NOTE: this is only relevant for Linux hosts
|
||||
# (doesn't apply in Docker Desktop)
|
||||
# (does not apply in Docker Desktop)
|
||||
propagation_modes = [
|
||||
'rshared',
|
||||
'shared',
|
||||
@@ -391,7 +391,7 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None, environment=None):
|
||||
|
||||
if not tls_verify and assert_hostname is None:
|
||||
# assert_hostname is a subset of TLS verification,
|
||||
# so if it's not set already then set it to false.
|
||||
# so if it is not set already then set it to false.
|
||||
assert_hostname = False
|
||||
|
||||
params['tls'] = TLSConfig(
|
||||
|
||||
@@ -69,9 +69,9 @@ except ImportError:
|
||||
try:
|
||||
from requests.exceptions import RequestException # noqa: F401, pylint: disable=unused-import
|
||||
except ImportError:
|
||||
# Either Docker SDK for Python is no longer using requests, or Docker SDK for Python isn't around either,
|
||||
# Either Docker SDK for Python is no longer using requests, or Docker SDK for Python is not around either,
|
||||
# or Docker SDK for Python's dependency requests is missing. In any case, define an exception
|
||||
# class RequestException so that our code doesn't break.
|
||||
# class RequestException so that our code does not break.
|
||||
class RequestException(Exception):
|
||||
pass
|
||||
|
||||
@@ -440,7 +440,7 @@ class AnsibleDockerClientBase(Client):
|
||||
registry, repo_name = auth.resolve_repository_name(name)
|
||||
if registry == 'docker.io':
|
||||
# If docker.io is explicitly there in name, the image
|
||||
# isn't found in some cases (#41509)
|
||||
# is not found in some cases (#41509)
|
||||
self.log("Check for docker.io image: %s" % repo_name)
|
||||
images = self._image_lookup(repo_name, tag)
|
||||
if not images and repo_name.startswith('library/'):
|
||||
@@ -449,8 +449,8 @@ class AnsibleDockerClientBase(Client):
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
images = self._image_lookup(lookup, tag)
|
||||
if not images:
|
||||
# Last case for some Docker versions: if docker.io wasn't there,
|
||||
# it can be that the image wasn't found either
|
||||
# Last case for some Docker versions: if docker.io was not there,
|
||||
# it can be that the image was not found either
|
||||
# (https://github.com/ansible/ansible/pull/15586)
|
||||
lookup = "%s/%s" % (registry, repo_name)
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
|
||||
@@ -21,7 +21,7 @@ from ansible_collections.community.docker.plugins.module_utils.version import Lo
|
||||
try:
|
||||
from requests.exceptions import RequestException, SSLError # noqa: F401, pylint: disable=unused-import
|
||||
except ImportError:
|
||||
# Define an exception class RequestException so that our code doesn't break.
|
||||
# Define an exception class RequestException so that our code does not break.
|
||||
class RequestException(Exception):
|
||||
pass
|
||||
|
||||
@@ -366,7 +366,7 @@ class AnsibleDockerClientBase(Client):
|
||||
registry, repo_name = auth.resolve_repository_name(name)
|
||||
if registry == 'docker.io':
|
||||
# If docker.io is explicitly there in name, the image
|
||||
# isn't found in some cases (#41509)
|
||||
# is not found in some cases (#41509)
|
||||
self.log("Check for docker.io image: %s" % repo_name)
|
||||
images = self._image_lookup(repo_name, tag)
|
||||
if not images and repo_name.startswith('library/'):
|
||||
@@ -375,8 +375,8 @@ class AnsibleDockerClientBase(Client):
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
images = self._image_lookup(lookup, tag)
|
||||
if not images:
|
||||
# Last case for some Docker versions: if docker.io wasn't there,
|
||||
# it can be that the image wasn't found either
|
||||
# Last case for some Docker versions: if docker.io was not there,
|
||||
# it can be that the image was not found either
|
||||
# (https://github.com/ansible/ansible/pull/15586)
|
||||
lookup = "%s/%s" % (registry, repo_name)
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
|
||||
@@ -120,7 +120,7 @@ class AnsibleDockerClientBase(object):
|
||||
@abc.abstractmethod
|
||||
# def call_cli(self, *args, check_rc=False, data=None, cwd=None, environ_update=None):
|
||||
def call_cli(self, *args, **kwargs):
|
||||
# Python 2.7 doesn't like anything than '**kwargs' after '*args', so we have to do this manually...
|
||||
# Python 2.7 does not like anything than '**kwargs' after '*args', so we have to do this manually...
|
||||
pass
|
||||
|
||||
# def call_cli_json(self, *args, check_rc=False, data=None, cwd=None, environ_update=None, warn_on_stderr=False):
|
||||
@@ -220,7 +220,7 @@ class AnsibleDockerClientBase(object):
|
||||
registry, repo_name = resolve_repository_name(name)
|
||||
if registry == 'docker.io':
|
||||
# If docker.io is explicitly there in name, the image
|
||||
# isn't found in some cases (#41509)
|
||||
# is not found in some cases (#41509)
|
||||
self.log("Check for docker.io image: %s" % repo_name)
|
||||
images = self._image_lookup(repo_name, tag)
|
||||
if not images and repo_name.startswith('library/'):
|
||||
@@ -229,8 +229,8 @@ class AnsibleDockerClientBase(object):
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
images = self._image_lookup(lookup, tag)
|
||||
if not images:
|
||||
# Last case for some Docker versions: if docker.io wasn't there,
|
||||
# it can be that the image wasn't found either
|
||||
# Last case for some Docker versions: if docker.io was not there,
|
||||
# it can be that the image was not found either
|
||||
# (https://github.com/ansible/ansible/pull/15586)
|
||||
lookup = "%s/%s" % (registry, repo_name)
|
||||
self.log("Check for docker.io image: %s" % lookup)
|
||||
@@ -322,7 +322,7 @@ class AnsibleModuleDockerClient(AnsibleDockerClientBase):
|
||||
|
||||
# def call_cli(self, *args, check_rc=False, data=None, cwd=None, environ_update=None):
|
||||
def call_cli(self, *args, **kwargs):
|
||||
# Python 2.7 doesn't like anything than '**kwargs' after '*args', so we have to do this manually...
|
||||
# Python 2.7 does not like anything than '**kwargs' after '*args', so we have to do this manually...
|
||||
check_rc = kwargs.pop('check_rc', False)
|
||||
data = kwargs.pop('data', None)
|
||||
cwd = kwargs.pop('cwd', None)
|
||||
|
||||
@@ -841,7 +841,7 @@ class BaseComposeManager(DockerBaseClass):
|
||||
|
||||
def cleanup_result(self, result):
|
||||
if not result.get('failed'):
|
||||
# Only return stdout and stderr if it's not empty
|
||||
# Only return stdout and stderr if it is not empty
|
||||
for res in ('stdout', 'stderr'):
|
||||
if result.get(res) == '':
|
||||
result.pop(res)
|
||||
@@ -851,5 +851,5 @@ class BaseComposeManager(DockerBaseClass):
|
||||
try:
|
||||
shutil.rmtree(dir, True)
|
||||
except Exception:
|
||||
# shouldn't happen, but simply ignore to be on the safe side
|
||||
# should not happen, but simply ignore to be on the safe side
|
||||
pass
|
||||
|
||||
@@ -41,7 +41,7 @@ class ImageArchiveInvalidException(Exception):
|
||||
|
||||
super(ImageArchiveInvalidException, self).__init__(message)
|
||||
|
||||
# Python 2 doesn't support causes
|
||||
# Python 2 does not support causes
|
||||
self.cause = cause
|
||||
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ class DockerAPIEngineDriver(EngineDriver):
|
||||
except APIError as exc:
|
||||
if 'Unpause the container before stopping or killing' in exc.explanation:
|
||||
# New docker daemon versions do not allow containers to be removed
|
||||
# if they are paused. Make sure we don't end up in an infinite loop.
|
||||
# if they are paused. Make sure we do not end up in an infinite loop.
|
||||
if count == 3:
|
||||
raise Exception('%s [tried to unpause three times]' % to_native(exc))
|
||||
count += 1
|
||||
@@ -379,7 +379,7 @@ class DockerAPIEngineDriver(EngineDriver):
|
||||
except APIError as exc:
|
||||
if 'Unpause the container before stopping or killing' in exc.explanation:
|
||||
# New docker daemon versions do not allow containers to be removed
|
||||
# if they are paused. Make sure we don't end up in an infinite loop.
|
||||
# if they are paused. Make sure we do not end up in an infinite loop.
|
||||
if count == 3:
|
||||
raise Exception('%s [tried to unpause three times]' % to_native(exc))
|
||||
count += 1
|
||||
@@ -802,7 +802,7 @@ def _get_image_labels(image):
|
||||
if not image:
|
||||
return {}
|
||||
|
||||
# Can't use get('Labels', {}) because 'Labels' may be present and be None
|
||||
# Cannot use get('Labels', {}) because 'Labels' may be present and be None
|
||||
return image['Config'].get('Labels') or {}
|
||||
|
||||
|
||||
@@ -1267,7 +1267,7 @@ def _preprocess_container_names(module, client, api_version, value):
|
||||
# name (and in the latter case, retrieve its ID)
|
||||
container = client.get_container(container_name)
|
||||
if container is None:
|
||||
# If we can't find the container, issue a warning and continue with
|
||||
# If we cannot find the container, issue a warning and continue with
|
||||
# what the user specified.
|
||||
module.warn('Cannot find a container with name or ID "{0}"'.format(container_name))
|
||||
return value
|
||||
|
||||
@@ -461,7 +461,7 @@ class ContainerManager(DockerBaseClass):
|
||||
self.results['changed'] = True
|
||||
self.results['actions'].append(dict(pulled_image="%s:%s" % (repository, tag), changed=True))
|
||||
elif not image or self.param_pull_check_mode_behavior == 'always':
|
||||
# If the image isn't there, or pull_check_mode_behavior == 'always', claim we'll
|
||||
# If the image is not there, or pull_check_mode_behavior == 'always', claim we'll
|
||||
# pull. (Implicitly: if the image is there, claim it already was latest unless
|
||||
# pull_check_mode_behavior == 'always'.)
|
||||
self.results['changed'] = True
|
||||
|
||||
@@ -57,7 +57,7 @@ def shutdown_writing(sock, log=_empty_writer):
|
||||
|
||||
def write_to_socket(sock, data):
|
||||
if hasattr(sock, '_send_until_done'):
|
||||
# WrappedSocket (urllib3/contrib/pyopenssl) doesn't have `send`, but
|
||||
# WrappedSocket (urllib3/contrib/pyopenssl) does not have `send`, but
|
||||
# only `sendall`, which uses `_send_until_done` under the hood.
|
||||
return sock._send_until_done(data)
|
||||
elif hasattr(sock, 'send'):
|
||||
|
||||
@@ -210,7 +210,7 @@ def compare_generic(a, b, method, datatype):
|
||||
# If we would know that both a and b do not contain duplicates,
|
||||
# we could simply compare len(a) to len(b) to finish this test.
|
||||
# We can assume that b has no duplicates (as it is returned by
|
||||
# docker), but we don't know for a.
|
||||
# docker), but we do not know for a.
|
||||
for bv in b:
|
||||
found = False
|
||||
for av in a:
|
||||
@@ -303,7 +303,7 @@ def sanitize_labels(labels, labels_field, client=None, module=None):
|
||||
|
||||
def clean_dict_booleans_for_docker_api(data, allow_sequences=False):
|
||||
'''
|
||||
Go doesn't like Python booleans 'True' or 'False', while Ansible is just
|
||||
Go does not like Python booleans 'True' or 'False', while Ansible is just
|
||||
fine with them in YAML. As such, they need to be converted in cases where
|
||||
we pass dictionaries to the Docker API (e.g. docker_network's
|
||||
driver_options and docker_prune's filters). When `allow_sequences=True`
|
||||
|
||||
Reference in New Issue
Block a user