Skip to content

Commit

Permalink
Merge pull request #16418 from jakegt1/main
Browse files Browse the repository at this point in the history
Fix compat build API returning two JSON objects at once
  • Loading branch information
openshift-merge-robot authored Nov 7, 2022
2 parents e300c26 + 85f4d37 commit 9e04bab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
if err := enc.Encode(m); err != nil {
logrus.Warnf("failed to json encode error %v", err)
}
flush()
m.Aux = nil
m.Stream = fmt.Sprintf("Successfully built %12.12s\n", imageID)
if err := enc.Encode(m); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions test/python/docker/compat/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io
import os
import unittest
import json

from docker import errors

Expand Down Expand Up @@ -125,6 +126,14 @@ def test_build_image(self):
self.assertEqual(image.labels["apple"], labels["apple"])
self.assertEqual(image.labels["grape"], labels["grape"])

def test_build_image_via_api_client(self):
api_client = self.docker.api
for line in api_client.build(path="test/python/docker/build_labels"):
try:
parsed = json.loads(line.decode("utf-8"))
except json.JSONDecodeError as e:
raise IOError(f"Line '{line}' was not JSON parsable")
assert "errorDetail" not in parsed

if __name__ == "__main__":
# Setup temporary space
Expand Down

0 comments on commit 9e04bab

Please sign in to comment.