Skip to content

Commit 98fe5cf

Browse files
hack/build-image: apply black style formatting
Some `black` and `flake8` fixes. Signed-off-by: John Mulligan <[email protected]>
1 parent 7dd45ad commit 98fe5cf

File tree

1 file changed

+54
-23
lines changed

1 file changed

+54
-23
lines changed

hack/build-image

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ DEVBUILDS = "devbuilds"
102102
PACKAGE_SOURCES = [DEFAULT, NIGHTLY, DEVBUILDS]
103103

104104
PACKAGES_FROM = {
105-
DEFAULT: '',
106-
NIGHTLY: 'samba-nightly',
107-
DEVBUILDS: 'devbuilds',
105+
DEFAULT: "",
106+
NIGHTLY: "samba-nightly",
107+
DEVBUILDS: "devbuilds",
108108
}
109109

110110
# SOURCE_DIRS - image source paths
@@ -121,7 +121,7 @@ DEFAULT_DISTRO_BASES = [FEDORA]
121121
LATEST = "latest"
122122
QUAL_NONE = "unqualified"
123123
QUAL_DISTRO = "distro-qualified"
124-
QUAL_FQIN = 'fqin'
124+
QUAL_FQIN = "fqin"
125125

126126

127127
_DISCOVERED_CONTAINER_ENGINES = []
@@ -207,45 +207,71 @@ def container_build(cli, target):
207207
tasks = []
208208

209209
# For docker cross-builds we need to use buildx
210-
if "docker" in eng and target.arch != host_arch():
210+
if "docker" in eng and target.arch != host_arch():
211211
args = [eng, "buildx"]
212212

213213
# Docker's default builder only supports the host architecture.
214214
# Therefore, we need to create a new builder to support other
215215
# architectures, and we must ensure we start with a fresh builder
216216
# that does not contain any images from previous builds.
217-
tasks.append(lambda : run(cli, args + ["rm", target.flat_name()], check=False))
218-
tasks.append(lambda : run(cli, args + ["create", f"--name={target.flat_name()}"], check=True))
217+
tasks.append(
218+
lambda: run(cli, args + ["rm", target.flat_name()], check=False)
219+
)
220+
tasks.append(
221+
lambda: run(
222+
cli,
223+
args + ["create", f"--name={target.flat_name()}"],
224+
check=True,
225+
)
226+
)
219227

220-
tasks.append(lambda : run(cli, args + [
221-
"build",
222-
f"--builder={target.flat_name()}",
223-
f"--platform=linux/{target.arch}",
224-
"--load"] + create_common_container_engine_args(cli, target), check=True))
228+
tasks.append(
229+
lambda: run(
230+
cli,
231+
args
232+
+ [
233+
"build",
234+
f"--builder={target.flat_name()}",
235+
f"--platform=linux/{target.arch}",
236+
"--load",
237+
]
238+
+ create_common_container_engine_args(cli, target),
239+
check=True,
240+
)
241+
)
225242

226-
tasks.append(lambda : run(cli, args + ["rm", target.flat_name()], check=True))
243+
tasks.append(
244+
lambda: run(cli, args + ["rm", target.flat_name()], check=True)
245+
)
227246
else:
228247
args = [eng, "build"]
229248
if target.arch != host_arch() or FORCE_ARCH_FLAG:
230-
# We've noticed a few small quirks when using podman with the --arch
231-
# option. The main issue is that building the client image works
232-
# but then the toolbox image fails because it somehow doesn't see
233-
# the image we just built as usable. This doesn't happen when
249+
# We've noticed a few small quirks when using podman with the
250+
# --arch option. The main issue is that building the client image
251+
# works but then the toolbox image fails because it somehow doesn't
252+
# see the image we just built as usable. This doesn't happen when
234253
# --arch is not provided. So if the target arch and the host_arch
235254
# are the same, skip passing the extra argument.
236255
args += [f"--arch={target.arch}"]
237256

238-
tasks.append(lambda : run(cli, args + create_common_container_engine_args(cli, target), check=True))
257+
tasks.append(
258+
lambda: run(
259+
cli,
260+
args + create_common_container_engine_args(cli, target),
261+
check=True,
262+
)
263+
)
239264

240265
for task in tasks:
241266
task()
242267

268+
243269
def create_common_container_engine_args(cli, target):
244270
args = []
245271
pkgs_from = PACKAGES_FROM[target.pkg_source]
246272
if pkgs_from:
247273
args.append(f"--build-arg=INSTALL_PACKAGES_FROM={pkgs_from}")
248-
274+
249275
if cli.extra_build_arg:
250276
args.extend(cli.extra_build_arg)
251277

@@ -258,6 +284,7 @@ def create_common_container_engine_args(cli, target):
258284
args.append(kind_source_dir(target.name))
259285
return [str(a) for a in args]
260286

287+
261288
def container_push(cli, push_name):
262289
"""Construct and execute a command to push a container image."""
263290
args = [container_engine(cli), "push", push_name]
@@ -306,7 +333,9 @@ def kind_source_dir(kind):
306333

307334
def target_containerfile(target):
308335
"""Return the path to a containerfile given an image target."""
309-
return str(kind_source_dir(target.name) / f"Containerfile.{target.distro}")
336+
return str(
337+
kind_source_dir(target.name) / f"Containerfile.{target.distro}"
338+
)
310339

311340

312341
def host_arch():
@@ -659,7 +688,7 @@ def main():
659688
parser.add_argument(
660689
"--push-selected-tags",
661690
type=QMatcher,
662-
help=QMatcher.__doc__
691+
help=QMatcher.__doc__,
663692
)
664693
parser.add_argument(
665694
"--buildfile-prefix",
@@ -724,8 +753,10 @@ def main():
724753
action="store_const",
725754
dest="main_action",
726755
const=retag,
727-
help=("Regenerate any short (unqualified) tags expected to exist"
728-
" for a given FQIN. Requires FQIN to already exist locally."),
756+
help=(
757+
"Regenerate any short (unqualified) tags expected to exist"
758+
" for a given FQIN. Requires FQIN to already exist locally."
759+
),
729760
)
730761
cli = parser.parse_args()
731762

0 commit comments

Comments
 (0)