mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-03-16 04:04:31 +00:00
Address invalid-name.
This commit is contained in:
parent
c7399b7c38
commit
ae0dba8490
@ -384,7 +384,6 @@ disable=raw-checker-failed,
|
|||||||
consider-using-with,
|
consider-using-with,
|
||||||
fixme,
|
fixme,
|
||||||
import-error, # TODO figure out why pylint cannot find the module
|
import-error, # TODO figure out why pylint cannot find the module
|
||||||
invalid-name,
|
|
||||||
keyword-arg-before-vararg,
|
keyword-arg-before-vararg,
|
||||||
line-too-long,
|
line-too-long,
|
||||||
no-else-continue,
|
no-else-continue,
|
||||||
|
|||||||
@ -574,7 +574,11 @@ class Connection(ConnectionBase):
|
|||||||
# Older docker does not have native support for fetching files command `cp`
|
# Older docker does not have native support for fetching files command `cp`
|
||||||
# If `cp` fails, try to use `dd` instead
|
# If `cp` fails, try to use `dd` instead
|
||||||
args = self._build_exec_cmd(
|
args = self._build_exec_cmd(
|
||||||
[self._play_context.executable, "-c", f"dd if={in_path} bs={BUFSIZE}"]
|
[
|
||||||
|
self._play_context.executable,
|
||||||
|
"-c",
|
||||||
|
f"dd if={in_path} bs={BUFSIZE}",
|
||||||
|
]
|
||||||
)
|
)
|
||||||
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]
|
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]
|
||||||
with open(
|
with open(
|
||||||
|
|||||||
@ -125,16 +125,16 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
|
|
||||||
NAME = "community.docker.docker_machine"
|
NAME = "community.docker.docker_machine"
|
||||||
|
|
||||||
DOCKER_MACHINE_PATH = None
|
docker_machine_path = None
|
||||||
|
|
||||||
def _run_command(self, args):
|
def _run_command(self, args):
|
||||||
if not self.DOCKER_MACHINE_PATH:
|
if not self.docker_machine_path:
|
||||||
try:
|
try:
|
||||||
self.DOCKER_MACHINE_PATH = get_bin_path("docker-machine")
|
self.docker_machine_path = get_bin_path("docker-machine")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise AnsibleError(to_native(e))
|
raise AnsibleError(to_native(e))
|
||||||
|
|
||||||
command = [self.DOCKER_MACHINE_PATH]
|
command = [self.docker_machine_path]
|
||||||
command.extend(args)
|
command.extend(args)
|
||||||
display.debug(f"Executing command {command}")
|
display.debug(f"Executing command {command}")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -70,14 +70,16 @@ except ImportError:
|
|||||||
self.connection = self
|
self.connection = self
|
||||||
self.connectionpool = self
|
self.connectionpool = self
|
||||||
|
|
||||||
self.RecentlyUsedContainer = object()
|
self.RecentlyUsedContainer = object() # pylint: disable=invalid-name
|
||||||
self.PoolManager = object()
|
self.PoolManager = object() # pylint: disable=invalid-name
|
||||||
self.match_hostname = object()
|
self.match_hostname = object()
|
||||||
self.HTTPConnectionPool = _HTTPConnectionPool
|
self.HTTPConnectionPool = ( # pylint: disable=invalid-name
|
||||||
|
_HTTPConnectionPool
|
||||||
|
)
|
||||||
|
|
||||||
class FakeURLLIB3Connection:
|
class FakeURLLIB3Connection:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.HTTPConnection = _HTTPConnection
|
self.HTTPConnection = _HTTPConnection # pylint: disable=invalid-name
|
||||||
|
|
||||||
urllib3 = FakeURLLIB3()
|
urllib3 = FakeURLLIB3()
|
||||||
urllib3_connection = FakeURLLIB3Connection()
|
urllib3_connection = FakeURLLIB3Connection()
|
||||||
|
|||||||
@ -238,11 +238,11 @@ class Context:
|
|||||||
return self.context_type is None
|
return self.context_type is None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Name(self):
|
def Name(self): # pylint: disable=invalid-name
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Host(self):
|
def Host(self): # pylint: disable=invalid-name
|
||||||
if not self.orchestrator or self.orchestrator == "swarm":
|
if not self.orchestrator or self.orchestrator == "swarm":
|
||||||
endpoint = self.endpoints.get("docker", None)
|
endpoint = self.endpoints.get("docker", None)
|
||||||
if endpoint:
|
if endpoint:
|
||||||
@ -252,18 +252,18 @@ class Context:
|
|||||||
return self.endpoints[self.orchestrator].get("Host", None)
|
return self.endpoints[self.orchestrator].get("Host", None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Orchestrator(self):
|
def Orchestrator(self): # pylint: disable=invalid-name
|
||||||
return self.orchestrator
|
return self.orchestrator
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Metadata(self):
|
def Metadata(self): # pylint: disable=invalid-name
|
||||||
meta = {}
|
meta = {}
|
||||||
if self.orchestrator:
|
if self.orchestrator:
|
||||||
meta = {"StackOrchestrator": self.orchestrator}
|
meta = {"StackOrchestrator": self.orchestrator}
|
||||||
return {"Name": self.name, "Metadata": meta, "Endpoints": self.endpoints}
|
return {"Name": self.name, "Metadata": meta, "Endpoints": self.endpoints}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def TLSConfig(self):
|
def TLSConfig(self): # pylint: disable=invalid-name
|
||||||
key = self.orchestrator
|
key = self.orchestrator
|
||||||
if not key or key == "swarm":
|
if not key or key == "swarm":
|
||||||
key = "docker"
|
key = "docker"
|
||||||
@ -272,7 +272,7 @@ class Context:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def TLSMaterial(self):
|
def TLSMaterial(self): # pylint: disable=invalid-name
|
||||||
certs = {}
|
certs = {}
|
||||||
for endpoint, tls in self.tls_cfg.items():
|
for endpoint, tls in self.tls_cfg.items():
|
||||||
cert, key = tls.cert
|
cert, key = tls.cert
|
||||||
@ -280,5 +280,5 @@ class Context:
|
|||||||
return {"TLSMaterial": certs}
|
return {"TLSMaterial": certs}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Storage(self):
|
def Storage(self): # pylint: disable=invalid-name
|
||||||
return {"Storage": {"MetadataPath": self.meta_path, "TLSPath": self.tls_path}}
|
return {"Storage": {"MetadataPath": self.meta_path, "TLSPath": self.tls_path}}
|
||||||
|
|||||||
@ -28,9 +28,9 @@ except ImportError:
|
|||||||
PYWIN32_IMPORT_ERROR = traceback.format_exc()
|
PYWIN32_IMPORT_ERROR = traceback.format_exc()
|
||||||
|
|
||||||
|
|
||||||
cERROR_PIPE_BUSY = 0xE7
|
ERROR_PIPE_BUSY = 0xE7
|
||||||
cSECURITY_SQOS_PRESENT = 0x100000
|
SECURITY_SQOS_PRESENT = 0x100000
|
||||||
cSECURITY_ANONYMOUS = 0
|
SECURITY_ANONYMOUS = 0
|
||||||
|
|
||||||
MAXIMUM_RETRY_COUNT = 10
|
MAXIMUM_RETRY_COUNT = 10
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ class NpipeSocket:
|
|||||||
None,
|
None,
|
||||||
win32file.OPEN_EXISTING,
|
win32file.OPEN_EXISTING,
|
||||||
(
|
(
|
||||||
cSECURITY_ANONYMOUS
|
SECURITY_ANONYMOUS
|
||||||
| cSECURITY_SQOS_PRESENT
|
| SECURITY_SQOS_PRESENT
|
||||||
| win32file.FILE_FLAG_OVERLAPPED
|
| win32file.FILE_FLAG_OVERLAPPED
|
||||||
),
|
),
|
||||||
0,
|
0,
|
||||||
@ -88,7 +88,7 @@ class NpipeSocket:
|
|||||||
except win32pipe.error as e:
|
except win32pipe.error as e:
|
||||||
# See Remarks:
|
# See Remarks:
|
||||||
# https://msdn.microsoft.com/en-us/library/aa365800.aspx
|
# https://msdn.microsoft.com/en-us/library/aa365800.aspx
|
||||||
if e.winerror == cERROR_PIPE_BUSY:
|
if e.winerror == ERROR_PIPE_BUSY:
|
||||||
# Another program or thread has grabbed our pipe instance
|
# Another program or thread has grabbed our pipe instance
|
||||||
# before we got to it. Wait for availability and attempt to
|
# before we got to it. Wait for availability and attempt to
|
||||||
# connect again.
|
# connect again.
|
||||||
|
|||||||
@ -98,7 +98,7 @@ MIN_DOCKER_VERSION = "1.8.0"
|
|||||||
|
|
||||||
|
|
||||||
if not HAS_DOCKER_PY:
|
if not HAS_DOCKER_PY:
|
||||||
docker_version = None
|
docker_version = None # pylint: disable=invalid-name
|
||||||
|
|
||||||
# No Docker SDK for Python. Create a place holder client to allow
|
# No Docker SDK for Python. Create a place holder client to allow
|
||||||
# instantiation of AnsibleModule and proper error handing
|
# instantiation of AnsibleModule and proper error handing
|
||||||
@ -194,7 +194,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
def __init__(self, min_docker_version=None, min_docker_api_version=None):
|
def __init__(self, min_docker_version=None, min_docker_api_version=None):
|
||||||
if min_docker_version is None:
|
if min_docker_version is None:
|
||||||
min_docker_version = MIN_DOCKER_VERSION
|
min_docker_version = MIN_DOCKER_VERSION
|
||||||
NEEDS_DOCKER_PY2 = LooseVersion(min_docker_version) >= LooseVersion("2.0.0")
|
needs_docker_py2 = LooseVersion(min_docker_version) >= LooseVersion("2.0.0")
|
||||||
|
|
||||||
self.docker_py_version = LooseVersion(docker_version)
|
self.docker_py_version = LooseVersion(docker_version)
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
f"Error: Docker SDK for Python version is {docker_version} ({platform.node()}'s Python {sys.executable})."
|
f"Error: Docker SDK for Python version is {docker_version} ({platform.node()}'s Python {sys.executable})."
|
||||||
f" Minimum version required is {min_docker_version}."
|
f" Minimum version required is {min_docker_version}."
|
||||||
)
|
)
|
||||||
if not NEEDS_DOCKER_PY2:
|
if not needs_docker_py2:
|
||||||
# The minimal required version is < 2.0 (and the current version as well).
|
# The minimal required version is < 2.0 (and the current version as well).
|
||||||
# Advertise docker (instead of docker-py).
|
# Advertise docker (instead of docker-py).
|
||||||
msg += DOCKERPYUPGRADE_RECOMMEND_DOCKER
|
msg += DOCKERPYUPGRADE_RECOMMEND_DOCKER
|
||||||
|
|||||||
@ -568,13 +568,13 @@ class ContainerManager(DockerBaseClass):
|
|||||||
if not image or self.param_pull == "always":
|
if not image or self.param_pull == "always":
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
self.log("Pull the image.")
|
self.log("Pull the image.")
|
||||||
image, alreadyToLatest = self.engine_driver.pull_image(
|
image, already_to_latest = self.engine_driver.pull_image(
|
||||||
self.client,
|
self.client,
|
||||||
repository,
|
repository,
|
||||||
tag,
|
tag,
|
||||||
image_platform=self.module.params["platform"],
|
image_platform=self.module.params["platform"],
|
||||||
)
|
)
|
||||||
if alreadyToLatest:
|
if already_to_latest:
|
||||||
self.results["changed"] = False
|
self.results["changed"] = False
|
||||||
self.results["actions"].append(
|
self.results["actions"].append(
|
||||||
dict(pulled_image=f"{repository}:{tag}", changed=False)
|
dict(pulled_image=f"{repository}:{tag}", changed=False)
|
||||||
|
|||||||
@ -969,9 +969,9 @@ class ImageManager(DockerBaseClass):
|
|||||||
|
|
||||||
if line.get("error"):
|
if line.get("error"):
|
||||||
if line.get("errorDetail"):
|
if line.get("errorDetail"):
|
||||||
errorDetail = line.get("errorDetail")
|
error_detail = line.get("errorDetail")
|
||||||
self.fail(
|
self.fail(
|
||||||
f"Error building {self.name} - code: {errorDetail.get('code')}, message: {errorDetail.get('message')}, logs: {build_output}"
|
f"Error building {self.name} - code: {error_detail.get('code')}, message: {error_detail.get('message')}, logs: {build_output}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.fail(
|
self.fail(
|
||||||
|
|||||||
@ -115,8 +115,8 @@ def fake_read_from_socket(self, response, stream, tty=False, demux=False):
|
|||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
|
||||||
url_base = f"{fake_api.prefix}/"
|
url_base = f"{fake_api.prefix}/" # pylint: disable=invalid-name
|
||||||
url_prefix = f"{url_base}v{DEFAULT_DOCKER_API_VERSION}/"
|
url_prefix = f"{url_base}v{DEFAULT_DOCKER_API_VERSION}/" # pylint: disable=invalid-name
|
||||||
|
|
||||||
|
|
||||||
class BaseAPIClientTest(unittest.TestCase):
|
class BaseAPIClientTest(unittest.TestCase):
|
||||||
@ -482,7 +482,7 @@ class TCPSocketStreamTest(unittest.TestCase):
|
|||||||
stderr_data = cls.stderr_data
|
stderr_data = cls.stderr_data
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
class Handler(BaseHTTPRequestHandler):
|
||||||
def do_POST(self):
|
def do_POST(self): # pylint: disable=invalid-name
|
||||||
resp_data = self.get_resp_data()
|
resp_data = self.get_resp_data()
|
||||||
self.send_response(101)
|
self.send_response(101)
|
||||||
self.send_header("Content-Type", "application/vnd.docker.raw-stream")
|
self.send_header("Content-Type", "application/vnd.docker.raw-stream")
|
||||||
|
|||||||
@ -537,9 +537,9 @@ def post_fake_secret():
|
|||||||
|
|
||||||
|
|
||||||
# Maps real api url to fake response callback
|
# Maps real api url to fake response callback
|
||||||
prefix = "http+docker://localhost"
|
prefix = "http+docker://localhost" # pylint: disable=invalid-name
|
||||||
if constants.IS_WINDOWS_PLATFORM:
|
if constants.IS_WINDOWS_PLATFORM:
|
||||||
prefix = "http+docker://localnpipe"
|
prefix = "http+docker://localnpipe" # pylint: disable=invalid-name
|
||||||
|
|
||||||
fake_responses = {
|
fake_responses = {
|
||||||
f"{prefix}/version": get_fake_version,
|
f"{prefix}/version": get_fake_version,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user