mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 19:42:06 +00:00
Fix typing info. (#1183)
This commit is contained in:
parent
00c480254d
commit
dee138bc4b
2
changelogs/fragments/typing.yml
Normal file
2
changelogs/fragments/typing.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_compose_v2_run - when ``detach=true``, ensure that the returned container ID is not a bytes string (https://github.com/ansible-collections/community.docker/pull/1183)."
|
||||||
@ -228,12 +228,12 @@ class Connection(ConnectionBase):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
) as p:
|
) as p:
|
||||||
out, err = p.communicate()
|
out_b, err_b = p.communicate()
|
||||||
out = to_text(out, errors="surrogate_or_strict")
|
out = to_text(out_b, errors="surrogate_or_strict")
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
display.warning(
|
display.warning(
|
||||||
f"unable to retrieve default user from docker container: {out} {to_text(err)}"
|
f"unable to retrieve default user from docker container: {out} {to_text(err_b)}"
|
||||||
)
|
)
|
||||||
self._container_user_cache[container] = None
|
self._container_user_cache[container] = None
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -116,9 +116,9 @@ class Connection(ConnectionBase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
cmd_parts = nsenter_cmd_parts + [cmd]
|
cmd_parts = nsenter_cmd_parts + [cmd]
|
||||||
cmd = to_bytes(" ".join(cmd_parts))
|
cmd_b = to_bytes(" ".join(cmd_parts))
|
||||||
|
|
||||||
display.vvv(f"EXEC {to_text(cmd)}", host=self._play_context.remote_addr)
|
display.vvv(f"EXEC {to_text(cmd_b)}", host=self._play_context.remote_addr)
|
||||||
display.debug("opening command with Popen()")
|
display.debug("opening command with Popen()")
|
||||||
|
|
||||||
master = None
|
master = None
|
||||||
@ -137,9 +137,9 @@ class Connection(ConnectionBase):
|
|||||||
display.debug(f"Unable to open pty: {e}")
|
display.debug(f"Unable to open pty: {e}")
|
||||||
|
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
cmd,
|
cmd_b,
|
||||||
shell=isinstance(cmd, (str, bytes)),
|
shell=True,
|
||||||
executable=executable if isinstance(cmd, (str, bytes)) else None,
|
executable=executable,
|
||||||
cwd=self.cwd,
|
cwd=self.cwd,
|
||||||
stdin=stdin,
|
stdin=stdin,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|||||||
@ -556,8 +556,8 @@ def parse_events(
|
|||||||
stderr_lines = stderr.splitlines()
|
stderr_lines = stderr.splitlines()
|
||||||
if stderr_lines and stderr_lines[-1] == b"":
|
if stderr_lines and stderr_lines[-1] == b"":
|
||||||
del stderr_lines[-1]
|
del stderr_lines[-1]
|
||||||
for index, line in enumerate(stderr_lines):
|
for index, line_b in enumerate(stderr_lines):
|
||||||
line = to_text(line.strip())
|
line = to_text(line_b.strip())
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
warn_missing_dry_run_prefix = False
|
warn_missing_dry_run_prefix = False
|
||||||
|
|||||||
@ -250,11 +250,11 @@ class ExecManager(BaseComposeManager):
|
|||||||
kwargs["data"] = self.stdin.encode("utf-8")
|
kwargs["data"] = self.stdin.encode("utf-8")
|
||||||
if self.detach:
|
if self.detach:
|
||||||
kwargs["check_rc"] = True
|
kwargs["check_rc"] = True
|
||||||
rc, stdout, stderr = self.client.call_cli(*args, **kwargs)
|
rc, stdout_b, stderr_b = self.client.call_cli(*args, **kwargs)
|
||||||
if self.detach:
|
if self.detach:
|
||||||
return {}
|
return {}
|
||||||
stdout = to_text(stdout)
|
stdout = to_text(stdout_b)
|
||||||
stderr = to_text(stderr)
|
stderr = to_text(stderr_b)
|
||||||
if self.strip_empty_ends:
|
if self.strip_empty_ends:
|
||||||
stdout = stdout.rstrip("\r\n")
|
stdout = stdout.rstrip("\r\n")
|
||||||
stderr = stderr.rstrip("\r\n")
|
stderr = stderr.rstrip("\r\n")
|
||||||
|
|||||||
@ -368,13 +368,13 @@ class ExecManager(BaseComposeManager):
|
|||||||
kwargs["data"] = self.stdin.encode("utf-8")
|
kwargs["data"] = self.stdin.encode("utf-8")
|
||||||
if self.detach:
|
if self.detach:
|
||||||
kwargs["check_rc"] = True
|
kwargs["check_rc"] = True
|
||||||
rc, stdout, stderr = self.client.call_cli(*args, **kwargs)
|
rc, stdout_b, stderr_b = self.client.call_cli(*args, **kwargs)
|
||||||
if self.detach:
|
if self.detach:
|
||||||
return {
|
return {
|
||||||
"container_id": stdout.strip(),
|
"container_id": to_text(stdout_b.strip()),
|
||||||
}
|
}
|
||||||
stdout = to_text(stdout)
|
stdout = to_text(stdout_b)
|
||||||
stderr = to_text(stderr)
|
stderr = to_text(stderr_b)
|
||||||
if self.strip_empty_ends:
|
if self.strip_empty_ends:
|
||||||
stdout = stdout.rstrip("\r\n")
|
stdout = stdout.rstrip("\r\n")
|
||||||
stderr = stderr.rstrip("\r\n")
|
stderr = stderr.rstrip("\r\n")
|
||||||
|
|||||||
@ -2381,12 +2381,12 @@ class DockerServiceManager:
|
|||||||
|
|
||||||
mode = raw_data["Spec"]["Mode"]
|
mode = raw_data["Spec"]["Mode"]
|
||||||
if "Replicated" in mode:
|
if "Replicated" in mode:
|
||||||
ds.mode = to_text("replicated", encoding="utf-8")
|
ds.mode = to_text("replicated", encoding="utf-8") # type: ignore
|
||||||
ds.replicas = mode["Replicated"]["Replicas"]
|
ds.replicas = mode["Replicated"]["Replicas"]
|
||||||
elif "Global" in mode:
|
elif "Global" in mode:
|
||||||
ds.mode = "global"
|
ds.mode = "global"
|
||||||
elif "ReplicatedJob" in mode:
|
elif "ReplicatedJob" in mode:
|
||||||
ds.mode = to_text("replicated-job", encoding="utf-8")
|
ds.mode = to_text("replicated-job", encoding="utf-8") # type: ignore
|
||||||
ds.replicas = mode["ReplicatedJob"]["TotalCompletions"]
|
ds.replicas = mode["ReplicatedJob"]["TotalCompletions"]
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown service mode: {mode}")
|
raise ValueError(f"Unknown service mode: {mode}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user