Skip to content

Commit 2f433b2

Browse files
committed
add logs
1 parent 1369ca2 commit 2f433b2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

plugincontainer/container_runner_base.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package plugincontainer
55

66
import (
7+
"bufio"
78
"bytes"
89
"context"
910
"errors"
@@ -198,13 +199,31 @@ func (c *containerRunner) Start(ctx context.Context) error {
198199
}
199200
}
200201

202+
fmt.Println("AUTO DOWNLOAD", c.autoDownload)
201203
// automatically pull the image if the image does not exist.
202204
if c.autoDownload && len(images) == 0 {
205+
fmt.Println("AUTO DOWNLOAD", "PULLING")
203206
c.logger.Info("image not found, pulling", "ref", ref)
204-
_, err := c.dockerClient.ImagePull(ctx, c.image, image.PullOptions{})
207+
image, err := c.dockerClient.ImagePull(ctx, c.image, image.PullOptions{})
205208
if err != nil {
206209
return fmt.Errorf("error pulling image: %w", err)
207210
}
211+
reader := bufio.NewReader(image)
212+
defer image.Close()
213+
var resp bytes.Buffer
214+
for {
215+
line, err := reader.ReadBytes('\n')
216+
if err != nil {
217+
// it could be EOF or read error
218+
// handle it
219+
break
220+
}
221+
resp.Write(line)
222+
resp.WriteByte('\n')
223+
}
224+
225+
// print it
226+
fmt.Println(resp.String())
208227
}
209228

210229
resp, err := c.dockerClient.ContainerCreate(ctx, c.containerConfig, c.hostConfig, c.networkConfig, nil, "")

0 commit comments

Comments
 (0)