Skip to content

Commit e485669

Browse files
hack/build-image: remove unnecessary uses of lambda
I find lambda to be a bit of an unpleasant thing and try to remove it when possible. Since all uses of lambda in this code are calling the same function we can remove the function (and unchanging) argument and have the variable section map to the run function's remaining kwargs. Signed-off-by: John Mulligan <[email protected]>
1 parent 7bdc2ad commit e485669

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

hack/build-image

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,33 +215,31 @@ def container_build(cli, target):
215215
# architectures, and we must ensure we start with a fresh builder
216216
# that does not contain any images from previous builds.
217217
tasks.append(
218-
lambda: run(cli, args + ["rm", target.flat_name()], check=False)
218+
{"cmd": args + ["rm", target.flat_name()], "check": False}
219219
)
220220
tasks.append(
221-
lambda: run(
222-
cli,
223-
args + ["create", f"--name={target.flat_name()}"],
224-
check=True,
225-
)
221+
{
222+
"cmd": args + ["create", f"--name={target.flat_name()}"],
223+
"check": True,
224+
}
226225
)
227226

228227
tasks.append(
229-
lambda: run(
230-
cli,
231-
args
228+
{
229+
"cmd": args
232230
+ [
233231
"build",
234232
f"--builder={target.flat_name()}",
235233
f"--platform=linux/{target.arch}",
236234
"--load",
237235
]
238236
+ create_common_container_engine_args(cli, target),
239-
check=True,
240-
)
237+
"check": True,
238+
}
241239
)
242240

243241
tasks.append(
244-
lambda: run(cli, args + ["rm", target.flat_name()], check=True)
242+
{"cmd": args + ["rm", target.flat_name()], "check": True}
245243
)
246244
else:
247245
args = [eng, "build"]
@@ -255,15 +253,15 @@ def container_build(cli, target):
255253
args += [f"--arch={target.arch}"]
256254

257255
tasks.append(
258-
lambda: run(
259-
cli,
260-
args + create_common_container_engine_args(cli, target),
261-
check=True,
262-
)
256+
{
257+
"cmd": args
258+
+ create_common_container_engine_args(cli, target),
259+
"check": True,
260+
}
263261
)
264262

265263
for task in tasks:
266-
task()
264+
run(cli, **task)
267265

268266

269267
def create_common_container_engine_args(cli, target):

0 commit comments

Comments
 (0)