File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,16 @@ def _render_params(kwargs) -> dict[str, list[Any]]:
204
204
if "labels" in kwargs :
205
205
params ["labels" ] = json .dumps (kwargs .get ("labels" ))
206
206
207
- if params ["dockerfile" ] is None :
208
- params ["dockerfile" ] = f".containerfile.{ random .getrandbits (160 ):x} "
207
+ def default (value , def_value ):
208
+ return def_value if value is None else value
209
+
210
+ params ["outputformat" ] = default (
211
+ params ["outputformat" ], "application/vnd.oci.image.manifest.v1+json"
212
+ )
213
+ params ["layers" ] = default (params ["layers" ], True )
214
+ params ["dockerfile" ] = default (
215
+ params ["dockerfile" ], f".containerfile.{ random .getrandbits (160 ):x} "
216
+ )
209
217
210
218
# Remove any unset parameters
211
219
return dict (filter (lambda i : i [1 ] is not None , params .items ()))
Original file line number Diff line number Diff line change 15
15
"""Images integration tests."""
16
16
17
17
import io
18
+ import json
18
19
import platform
19
20
import tarfile
20
21
import types
@@ -144,6 +145,19 @@ def test_build(self):
144
145
self .assertIsNotNone (image )
145
146
self .assertIsNotNone (image .id )
146
147
148
+ def test_build_cache (self ):
149
+ """Check that building twice the same image uses caching"""
150
+ buffer = io .StringIO ("""FROM quay.io/libpod/alpine_labels:latest\n LABEL test=value""" )
151
+ image , _ = self .client .images .build (fileobj = buffer )
152
+ buffer .seek (0 )
153
+ _ , stream = self .client .images .build (fileobj = buffer )
154
+ for line in stream :
155
+ # Search for a line with contents "-> Using cache <image id>"
156
+ parsed = json .loads (line )['stream' ]
157
+ if "Using cache" in parsed :
158
+ break
159
+ self .assertEqual (parsed .split ()[3 ], image .id )
160
+
147
161
def test_build_with_context (self ):
148
162
context = io .BytesIO ()
149
163
with tarfile .open (fileobj = context , mode = "w" ) as tar :
You can’t perform that action at this time.
0 commit comments