From 86ec91220a12c96de117711ac36ef64adf46602f Mon Sep 17 00:00:00 2001 From: ChendongSun Date: Wed, 6 Nov 2024 06:29:26 +0000 Subject: [PATCH] Add container.Output utility Signed-off-by: ChendongSun --- ...gration-Add-container-output-utility.patch | 51 +++++++++++++++++++ moby.spec | 7 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 0009-integration-Add-container-output-utility.patch diff --git a/0009-integration-Add-container-output-utility.patch b/0009-integration-Add-container-output-utility.patch new file mode 100644 index 0000000..c4ffdd7 --- /dev/null +++ b/0009-integration-Add-container-output-utility.patch @@ -0,0 +1,51 @@ +From 9ee331235a3affa082d5cb0028351182b89fd123 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= +Date: Thu, 22 Feb 2024 11:14:27 +0100 +Subject: [PATCH] integration: Add container.Output utility +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Extracted from https://github.com/moby/moby/commit/bfb810445c3c111478f5e0e6268ef334c38f38cf + +Signed-off-by: Paweł Gronowski +--- + integration/internal/container/container.go | 25 +++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +diff --git a/integration/internal/container/container.go b/integration/internal/container/container.go +index 0974ce6bf1..dac52999ae 100644 +--- a/integration/internal/container/container.go ++++ b/integration/internal/container/container.go +@@ -170,3 +170,28 @@ func Inspect(ctx context.Context, t *testing.T, apiClient client.APIClient, cont + + return c + } ++ ++type ContainerOutput struct { ++ Stdout, Stderr string ++} ++ ++// Output waits for the container to end running and returns its output. ++func Output(ctx context.Context, client client.APIClient, id string) (ContainerOutput, error) { ++ logs, err := client.ContainerLogs(ctx, id, container.LogsOptions{Follow: true, ShowStdout: true, ShowStderr: true}) ++ if err != nil { ++ return ContainerOutput{}, err ++ } ++ ++ defer logs.Close() ++ ++ var stdoutBuf, stderrBuf bytes.Buffer ++ _, err = stdcopy.StdCopy(&stdoutBuf, &stderrBuf, logs) ++ if err != nil { ++ return ContainerOutput{}, err ++ } ++ ++ return ContainerOutput{ ++ Stdout: stdoutBuf.String(), ++ Stderr: stderrBuf.String(), ++ }, nil ++} +-- +2.33.0 + diff --git a/moby.spec b/moby.spec index 7183dde..d7f41ed 100644 --- a/moby.spec +++ b/moby.spec @@ -7,7 +7,7 @@ Name: docker Version: 25.0.3 -Release: 15 +Release: 16 Summary: The open-source application container engine License: ASL 2.0 URL: https://www.docker.com @@ -28,6 +28,7 @@ Patch0005: 0005-CVE-2024-41110.patch Patch0006: 0006-tini.c-a-function-declaration-without-a-prototype-is.patch Patch0007: 0007-fix-libnetwork-osl-test-TestAddRemoveInterface.patch Patch0008: 0008-api-omit-missing-Created-field-from-ImageInspect-res.patch +Patch0009: 0009-integration-Add-container-output-utility.patch Requires: %{name}-engine = %{version}-%{release} Requires: %{name}-client = %{version}-%{release} @@ -98,6 +99,7 @@ Docker client binary and related utilities %patch 0005 -p1 %patch 0007 -p1 %patch 0008 -p1 +%patch 0009 -p1 %setup -q -T -n %{_source_docker_init} -b 2 %patch 0006 -p1 @@ -200,6 +202,9 @@ fi %systemd_postun_with_restart docker.service %changelog +* Wed Nov 6 2024 sunchendong - 25.0.3-16 +- DESC:Add container.Output utility + * Mon Nov 4 2024 sunchendong - 25.0.3-15 - DESC:omit missing Created field from ImageInspect response -- Gitee