Add container.Output utility
Signed-off-by: ChendongSun <sunchendong@xfusion.com>
This commit is contained in:
parent
74f5abf9d7
commit
86ec91220a
51
0009-integration-Add-container-output-utility.patch
Normal file
51
0009-integration-Add-container-output-utility.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 9ee331235a3affa082d5cb0028351182b89fd123 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= <pawel.gronowski@docker.com>
|
||||||
|
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 <pawel.gronowski@docker.com>
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
Name: docker
|
Name: docker
|
||||||
Version: 25.0.3
|
Version: 25.0.3
|
||||||
Release: 15
|
Release: 16
|
||||||
Summary: The open-source application container engine
|
Summary: The open-source application container engine
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://www.docker.com
|
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
|
Patch0006: 0006-tini.c-a-function-declaration-without-a-prototype-is.patch
|
||||||
Patch0007: 0007-fix-libnetwork-osl-test-TestAddRemoveInterface.patch
|
Patch0007: 0007-fix-libnetwork-osl-test-TestAddRemoveInterface.patch
|
||||||
Patch0008: 0008-api-omit-missing-Created-field-from-ImageInspect-res.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}-engine = %{version}-%{release}
|
||||||
Requires: %{name}-client = %{version}-%{release}
|
Requires: %{name}-client = %{version}-%{release}
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ Docker client binary and related utilities
|
|||||||
%patch 0005 -p1
|
%patch 0005 -p1
|
||||||
%patch 0007 -p1
|
%patch 0007 -p1
|
||||||
%patch 0008 -p1
|
%patch 0008 -p1
|
||||||
|
%patch 0009 -p1
|
||||||
%setup -q -T -n %{_source_docker_init} -b 2
|
%setup -q -T -n %{_source_docker_init} -b 2
|
||||||
%patch 0006 -p1
|
%patch 0006 -p1
|
||||||
|
|
||||||
@ -200,6 +202,9 @@ fi
|
|||||||
%systemd_postun_with_restart docker.service
|
%systemd_postun_with_restart docker.service
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 6 2024 sunchendong<sunchendong@xfusion.com> - 25.0.3-16
|
||||||
|
- DESC:Add container.Output utility
|
||||||
|
|
||||||
* Mon Nov 4 2024 sunchendong<sunchendong@xfusion.com> - 25.0.3-15
|
* Mon Nov 4 2024 sunchendong<sunchendong@xfusion.com> - 25.0.3-15
|
||||||
- DESC:omit missing Created field from ImageInspect response
|
- DESC:omit missing Created field from ImageInspect response
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user