mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-03-15 19:58:28 +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,
|
||||
fixme,
|
||||
import-error, # TODO figure out why pylint cannot find the module
|
||||
invalid-name,
|
||||
keyword-arg-before-vararg,
|
||||
line-too-long,
|
||||
no-else-continue,
|
||||
|
||||
@ -574,7 +574,11 @@ class Connection(ConnectionBase):
|
||||
# Older docker does not have native support for fetching files command `cp`
|
||||
# If `cp` fails, try to use `dd` instead
|
||||
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]
|
||||
with open(
|
||||
|
||||
@ -125,16 +125,16 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
|
||||
NAME = "community.docker.docker_machine"
|
||||
|
||||
DOCKER_MACHINE_PATH = None
|
||||
docker_machine_path = None
|
||||
|
||||
def _run_command(self, args):
|
||||
if not self.DOCKER_MACHINE_PATH:
|
||||
if not self.docker_machine_path:
|
||||
try:
|
||||
self.DOCKER_MACHINE_PATH = get_bin_path("docker-machine")
|
||||
self.docker_machine_path = get_bin_path("docker-machine")
|
||||
except ValueError as e:
|
||||
raise AnsibleError(to_native(e))
|
||||
|
||||
command = [self.DOCKER_MACHINE_PATH]
|
||||
command = [self.docker_machine_path]
|
||||
command.extend(args)
|
||||
display.debug(f"Executing command {command}")
|
||||
try:
|
||||
|
||||
@ -70,14 +70,16 @@ except ImportError:
|
||||
self.connection = self
|
||||
self.connectionpool = self
|
||||
|
||||
self.RecentlyUsedContainer = object()
|
||||
self.PoolManager = object()
|
||||
self.RecentlyUsedContainer = object() # pylint: disable=invalid-name
|
||||
self.PoolManager = object() # pylint: disable=invalid-name
|
||||
self.match_hostname = object()
|
||||
self.HTTPConnectionPool = _HTTPConnectionPool
|
||||
self.HTTPConnectionPool = ( # pylint: disable=invalid-name
|
||||
_HTTPConnectionPool
|
||||
)
|
||||
|
||||
class FakeURLLIB3Connection:
|
||||
def __init__(self):
|
||||
self.HTTPConnection = _HTTPConnection
|
||||
self.HTTPConnection = _HTTPConnection # pylint: disable=invalid-name
|
||||
|
||||
urllib3 = FakeURLLIB3()
|
||||
urllib3_connection = FakeURLLIB3Connection()
|
||||
|
||||
@ -238,11 +238,11 @@ class Context:
|
||||
return self.context_type is None
|
||||
|
||||
@property
|
||||
def Name(self):
|
||||
def Name(self): # pylint: disable=invalid-name
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def Host(self):
|
||||
def Host(self): # pylint: disable=invalid-name
|
||||
if not self.orchestrator or self.orchestrator == "swarm":
|
||||
endpoint = self.endpoints.get("docker", None)
|
||||
if endpoint:
|
||||
@ -252,18 +252,18 @@ class Context:
|
||||
return self.endpoints[self.orchestrator].get("Host", None)
|
||||
|
||||
@property
|
||||
def Orchestrator(self):
|
||||
def Orchestrator(self): # pylint: disable=invalid-name
|
||||
return self.orchestrator
|
||||
|
||||
@property
|
||||
def Metadata(self):
|
||||
def Metadata(self): # pylint: disable=invalid-name
|
||||
meta = {}
|
||||
if self.orchestrator:
|
||||
meta = {"StackOrchestrator": self.orchestrator}
|
||||
return {"Name": self.name, "Metadata": meta, "Endpoints": self.endpoints}
|
||||
|
||||
@property
|
||||
def TLSConfig(self):
|
||||
def TLSConfig(self): # pylint: disable=invalid-name
|
||||
key = self.orchestrator
|
||||
if not key or key == "swarm":
|
||||
key = "docker"
|
||||
@ -272,7 +272,7 @@ class Context:
|
||||
return None
|
||||
|
||||
@property
|
||||
def TLSMaterial(self):
|
||||
def TLSMaterial(self): # pylint: disable=invalid-name
|
||||
certs = {}
|
||||
for endpoint, tls in self.tls_cfg.items():
|
||||
cert, key = tls.cert
|
||||
@ -280,5 +280,5 @@ class Context:
|
||||
return {"TLSMaterial": certs}
|
||||
|
||||
@property
|
||||
def Storage(self):
|
||||
def Storage(self): # pylint: disable=invalid-name
|
||||
return {"Storage": {"MetadataPath": self.meta_path, "TLSPath": self.tls_path}}
|
||||
|
||||
@ -28,9 +28,9 @@ except ImportError:
|
||||
PYWIN32_IMPORT_ERROR = traceback.format_exc()
|
||||
|
||||
|
||||
cERROR_PIPE_BUSY = 0xE7
|
||||
cSECURITY_SQOS_PRESENT = 0x100000
|
||||
cSECURITY_ANONYMOUS = 0
|
||||
ERROR_PIPE_BUSY = 0xE7
|
||||
SECURITY_SQOS_PRESENT = 0x100000
|
||||
SECURITY_ANONYMOUS = 0
|
||||
|
||||
MAXIMUM_RETRY_COUNT = 10
|
||||
|
||||
@ -79,8 +79,8 @@ class NpipeSocket:
|
||||
None,
|
||||
win32file.OPEN_EXISTING,
|
||||
(
|
||||
cSECURITY_ANONYMOUS
|
||||
| cSECURITY_SQOS_PRESENT
|
||||
SECURITY_ANONYMOUS
|
||||
| SECURITY_SQOS_PRESENT
|
||||
| win32file.FILE_FLAG_OVERLAPPED
|
||||
),
|
||||
0,
|
||||
@ -88,7 +88,7 @@ class NpipeSocket:
|
||||
except win32pipe.error as e:
|
||||
# See Remarks:
|
||||
# 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
|
||||
# before we got to it. Wait for availability and attempt to
|
||||
# connect again.
|
||||
|
||||
@ -98,7 +98,7 @@ MIN_DOCKER_VERSION = "1.8.0"
|
||||
|
||||
|
||||
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
|
||||
# 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):
|
||||
if min_docker_version is None:
|
||||
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)
|
||||
|
||||
@ -218,7 +218,7 @@ class AnsibleDockerClientBase(Client):
|
||||
f"Error: Docker SDK for Python version is {docker_version} ({platform.node()}'s Python {sys.executable})."
|
||||
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).
|
||||
# Advertise docker (instead of docker-py).
|
||||
msg += DOCKERPYUPGRADE_RECOMMEND_DOCKER
|
||||
|
||||
@ -568,13 +568,13 @@ class ContainerManager(DockerBaseClass):
|
||||
if not image or self.param_pull == "always":
|
||||
if not self.check_mode:
|
||||
self.log("Pull the image.")
|
||||
image, alreadyToLatest = self.engine_driver.pull_image(
|
||||
image, already_to_latest = self.engine_driver.pull_image(
|
||||
self.client,
|
||||
repository,
|
||||
tag,
|
||||
image_platform=self.module.params["platform"],
|
||||
)
|
||||
if alreadyToLatest:
|
||||
if already_to_latest:
|
||||
self.results["changed"] = False
|
||||
self.results["actions"].append(
|
||||
dict(pulled_image=f"{repository}:{tag}", changed=False)
|
||||
|
||||
@ -969,9 +969,9 @@ class ImageManager(DockerBaseClass):
|
||||
|
||||
if line.get("error"):
|
||||
if line.get("errorDetail"):
|
||||
errorDetail = line.get("errorDetail")
|
||||
error_detail = line.get("errorDetail")
|
||||
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:
|
||||
self.fail(
|
||||
|
||||
@ -115,8 +115,8 @@ def fake_read_from_socket(self, response, stream, tty=False, demux=False):
|
||||
return b""
|
||||
|
||||
|
||||
url_base = f"{fake_api.prefix}/"
|
||||
url_prefix = f"{url_base}v{DEFAULT_DOCKER_API_VERSION}/"
|
||||
url_base = f"{fake_api.prefix}/" # pylint: disable=invalid-name
|
||||
url_prefix = f"{url_base}v{DEFAULT_DOCKER_API_VERSION}/" # pylint: disable=invalid-name
|
||||
|
||||
|
||||
class BaseAPIClientTest(unittest.TestCase):
|
||||
@ -482,7 +482,7 @@ class TCPSocketStreamTest(unittest.TestCase):
|
||||
stderr_data = cls.stderr_data
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
def do_POST(self): # pylint: disable=invalid-name
|
||||
resp_data = self.get_resp_data()
|
||||
self.send_response(101)
|
||||
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
|
||||
prefix = "http+docker://localhost"
|
||||
prefix = "http+docker://localhost" # pylint: disable=invalid-name
|
||||
if constants.IS_WINDOWS_PLATFORM:
|
||||
prefix = "http+docker://localnpipe"
|
||||
prefix = "http+docker://localnpipe" # pylint: disable=invalid-name
|
||||
|
||||
fake_responses = {
|
||||
f"{prefix}/version": get_fake_version,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user