Skip to content

Conversation

@jlebon
Copy link
Member

@jlebon jlebon commented Aug 27, 2025

This is basically the same as 2de6b0d ("cmd-build-with-buildah: make build existence check arch-aware") but for the import command.

This is basically the same as 2de6b0d ("cmd-build-with-buildah: make
build existence check arch-aware") but for the import command.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request makes the pre-existing build ID check in cmd-import architecture-aware, which is a good improvement for multi-architecture build support. The logic is correct. I have one suggestion to improve the efficiency of the check by avoiding iterating over the list of builds twice.

if builds.has(buildid):
print(f"ERROR: Build ID {buildid} already exists!")
arch = get_basearch()
if builds.has(buildid) and arch in builds.get_build_arches(buildid):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation correctly checks for the existence of the build for the given architecture, but it iterates over the list of builds twice: once in builds.has(buildid) and a second time in builds.get_build_arches(buildid).

This can be made more efficient by iterating only once. Here's a suggestion that achieves this using a generator expression with next().

Suggested change
if builds.has(buildid) and arch in builds.get_build_arches(buildid):
if arch in next((b.get('arches', []) for b in builds.get_builds() if b['id'] == buildid), []):

Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dustymabe dustymabe merged commit 661d6d6 into coreos:main Aug 27, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants