Skip to content

Commit 19eebd5

Browse files
Restore verbose image build output in kiln test
SuppressOutput was hardcoded to true and the logOutput writer was dropped when buildTestImage was extracted, silencing Docker build progress even with --verbose. Thread verbose through buildTestImage and restore the stream writer so build steps are visible when the flag is set. ai-assisted=yes Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a1fd222 commit 19eebd5

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

internal/test/container.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func runTest(ctx context.Context, w io.Writer, dockerDaemon mobyClient, configur
232232
envMap["ARTIFACTORY_USERNAME"] = username
233233
envMap["ARTIFACTORY_PASSWORD"] = password
234234

235-
if err := buildTestImage(ctx, w, dockerDaemon, username, password, envMap); err != nil {
235+
if err := buildTestImage(ctx, w, dockerDaemon, username, password, envMap, configuration.Verbose); err != nil {
236236
return err
237237
}
238238

@@ -245,26 +245,30 @@ func runTest(ctx context.Context, w io.Writer, dockerDaemon mobyClient, configur
245245

246246
// buildTestImage builds the kiln test Docker image, forwarding Artifactory
247247
// credentials as build args and registry auth for pulling base images.
248-
func buildTestImage(ctx context.Context, w io.Writer, dockerDaemon mobyClient, username, password string, envMap environmentVars) error {
248+
func buildTestImage(ctx context.Context, w io.Writer, dockerDaemon mobyClient, username, password string, envMap environmentVars, verbose bool) error {
249249
var dockerfileTarball bytes.Buffer
250250
if err := createDockerfileTarball(tar.NewWriter(&dockerfileTarball), dockerfile); err != nil {
251251
return err
252252
}
253253

254254
_, _ = fmt.Fprintln(w, "Preparing test image...")
255+
var logOutput io.Writer
256+
if verbose {
257+
logOutput = w
258+
}
255259
resp, err := dockerDaemon.ImageBuild(ctx, &dockerfileTarball, build.ImageBuildOptions{
256260
Tags: []string{"kiln_test_dependencies:vmware"},
257261
BuildArgs: map[string]*string{
258262
"ARTIFACTORY_USERNAME": &username,
259263
"ARTIFACTORY_PASSWORD": &password,
260264
},
261265
AuthConfigs: registryAuthForDockerVirtual(envMap),
262-
SuppressOutput: true,
266+
SuppressOutput: !verbose,
263267
})
264268
if err != nil {
265269
return fmt.Errorf("failed to build image: %w", err)
266270
}
267-
if err := checkImageBuildResponse(resp.Body); err != nil {
271+
if err := checkImageBuildResponse(resp.Body, logOutput); err != nil {
268272
return fmt.Errorf("image build failed: %w", err)
269273
}
270274
return nil
@@ -502,9 +506,10 @@ type imageBuildMessage struct {
502506
} `json:"errorDetail"`
503507
}
504508

505-
// checkImageBuildResponse reads the Docker/Podman image-build JSON stream and
506-
// returns any build error reported by the daemon.
507-
func checkImageBuildResponse(body io.ReadCloser) error {
509+
// checkImageBuildResponse reads the Docker/Podman image-build JSON stream. If
510+
// logOutput is non-nil, "stream" lines are written there. Build errors are
511+
// always returned.
512+
func checkImageBuildResponse(body io.ReadCloser, logOutput io.Writer) error {
508513
defer func() {
509514
_ = body.Close()
510515
}()
@@ -517,6 +522,9 @@ func checkImageBuildResponse(body io.ReadCloser) error {
517522
}
518523
return fmt.Errorf("failed to read image build response: %w", err)
519524
}
525+
if logOutput != nil && msg.Stream != "" {
526+
_, _ = io.WriteString(logOutput, msg.Stream)
527+
}
520528
if msg.Error != "" {
521529
detail := msg.Error
522530
if msg.ErrorDetail.Message != "" {

internal/test/container_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func Test_checkImageBuildResponse(t *testing.T) {
225225
`{"stream":"go: downloading\n"}` + "\n" +
226226
`{"error":"failed","errorDetail":{"message":"go install: nope"}}` + "\n",
227227
))
228-
err := checkImageBuildResponse(body)
228+
err := checkImageBuildResponse(body, nil)
229229
require.ErrorContains(t, err, "go install: nope")
230230
})
231231
}

0 commit comments

Comments
 (0)