Skip to content

Commit 512c861

Browse files
use kwargs.get default parameter for defaults
Replace function "default" inside _render_params in images_build.py with dict.get (kwargs.get) default value. Signed-off-by: Federico Rizzo <[email protected]>
1 parent 3cb64f5 commit 512c861

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

podman/domain/images_build.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _render_params(kwargs) -> dict[str, list[Any]]:
168168
raise PodmanError("Custom encoding not supported when gzip enabled.")
169169

170170
params = {
171-
"dockerfile": kwargs.get("dockerfile"),
171+
"dockerfile": kwargs.get("dockerfile", f".containerfile.{random.getrandbits(160):x}"),
172172
"forcerm": kwargs.get("forcerm"),
173173
"httpproxy": kwargs.get("http_proxy"),
174174
"networkmode": kwargs.get("network_mode"),
@@ -182,9 +182,11 @@ def _render_params(kwargs) -> dict[str, list[Any]]:
182182
"squash": kwargs.get("squash"),
183183
"t": kwargs.get("tag"),
184184
"target": kwargs.get("target"),
185-
"layers": kwargs.get("layers"),
185+
"layers": kwargs.get("layers", True),
186186
"output": kwargs.get("output"),
187-
"outputformat": kwargs.get("outputformat"),
187+
"outputformat": kwargs.get(
188+
"outputformat", "application/vnd.oci.image.manifest.v1+json"
189+
),
188190
}
189191

190192
if "buildargs" in kwargs:
@@ -205,16 +207,5 @@ def _render_params(kwargs) -> dict[str, list[Any]]:
205207
if "labels" in kwargs:
206208
params["labels"] = json.dumps(kwargs.get("labels"))
207209

208-
def default(value, def_value):
209-
return def_value if value is None else value
210-
211-
params["outputformat"] = default(
212-
params["outputformat"], "application/vnd.oci.image.manifest.v1+json"
213-
)
214-
params["layers"] = default(params["layers"], True)
215-
params["dockerfile"] = default(
216-
params["dockerfile"], f".containerfile.{random.getrandbits(160):x}"
217-
)
218-
219210
# Remove any unset parameters
220211
return dict(filter(lambda i: i[1] is not None, params.items()))

0 commit comments

Comments
 (0)