Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coreos/coreos-assembler
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3c6feeb1f1b16ad27e357c055f52f93d51684fd4
Choose a base ref
...
head repository: coreos/coreos-assembler
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e2c27099454f8e0029a4b51b492536bd133b1bca
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 17, 2025

  1. cmd-remote-build-container: add --git-containerfile

    For building the extensions, we need to be able to point buildah at the
    root of the git repo for the context dir but the Dockerfile in the
    `extensions/` subdirectory.
    
    Add a `--git-containerfile` for this.
    jlebon committed Mar 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jlebon Jonathan Lebon
    Copy the full SHA
    cdcc9eb View commit details
  2. cmd-remote-build-container: initialize submodules in git clone

    When cloning the git repo to pass to buildah, make sure to initiatlize
    submodules. E.g. building the extensions container requires parsing the
    manifest, which references bits in the fedora-coreos-config submodule.
    jlebon committed Mar 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jlebon Jonathan Lebon
    Copy the full SHA
    1cdb8e4 View commit details
  3. lib/container_manifest: check for image before manifest

    There's an asymmetry between `podman image exists` and `podman manifest
    exists`. The first will return 1 if the image is a manifest. The second
    will return 125 if the image is _not_ a manifest.
    
    I think this is probably a bug in podman, but for now we can work around
    this by reverting the order in which we do the checking. That way, if
    the image exists but isn't a manifest, we'll return `True` and not
    actually call `podman manifest exists` on it.
    jlebon committed Mar 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jlebon Jonathan Lebon
    Copy the full SHA
    e2c2709 View commit details
Showing with 15 additions and 7 deletions.
  1. +13 −5 src/cmd-remote-build-container
  2. +2 −2 src/cosalib/container_manifest.py
18 changes: 13 additions & 5 deletions src/cmd-remote-build-container
Original file line number Diff line number Diff line change
@@ -15,12 +15,13 @@ logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)s - %(message)s")


def build_container_image(labels, buildDir, fromimage, cacheTTL,
def build_container_image(labels, buildDir, containerfile, fromimage, cacheTTL,
repo, tag, secret, mount_ca, security_opt):
'''
Build the image using podman remote and push to the registry
@param labels list labels to add to image
@param buildDir str the location of the directory to build from
@param containerfile str the location of the containerfile relative to buildDir
@param fromimage str value to pass to `podman build --from=`
@param cacheTTL str value to pass to `podman build --cache-ttl=`
@param repo str registry repository
@@ -31,6 +32,8 @@ def build_container_image(labels, buildDir, fromimage, cacheTTL,
cmd.extend([f"--label={label}"])
if fromimage:
cmd.extend([f"--from={fromimage}"])
if containerfile:
cmd.extend([f"--file={containerfile}"])
if secret:
for s in secret:
cmd.append(f"--secret={s}")
@@ -147,6 +150,8 @@ def main():
runcmd(cmd, quiet=True, capture_output=True)
cmd = ["git", "-C", gitdir, "checkout", "FETCH_HEAD"]
runcmd(cmd, quiet=True, capture_output=True)
cmd = ["git", "-C", gitdir, "submodule", "update", "--recursive", "--init"]
runcmd(cmd, quiet=True, capture_output=True)
cmd = ["git", "-C", gitdir, "rev-parse", "FETCH_HEAD"]
commit = runcmd(cmd, quiet=True, capture_output=True).stdout.strip().decode()
shortcommit = commit[0:7]
@@ -180,10 +185,10 @@ def main():
if needbuild:
logging.info("Building container via podman")
builddir = os.path.join(gitdir, args.git_sub_dir)
build_container_image(args.labels, builddir, args.fromimage,
args.cache_ttl, args.repo, args.tag,
args.secret, args.mount_host_ca_certs,
args.security_opt)
build_container_image(args.labels, builddir, args.git_containerfile,
args.fromimage, args.cache_ttl,
args.repo, args.tag, args.secret,
args.mount_host_ca_certs, args.security_opt)

# Push to the registry if needed, else save the image to a file
if args.push_to_registry:
@@ -239,6 +244,9 @@ Examples:
parser.add_argument(
'--git-sub-dir', default='', required=False,
help='Git sub directory to use for container build')
parser.add_argument(
'--git-containerfile', default='', required=False,
help='Path to Containerfile (relative to git clone and sub dir, if specified)')
parser.add_argument(
'--label', dest="labels", default=[], action='append',
required=False, help='Add image label(s)')
4 changes: 2 additions & 2 deletions src/cosalib/container_manifest.py
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ def local_container_manifest_or_image_exists(repo, tag):
@param repo str registry repository
@param tag str tag
'''
cmds = [["podman", "manifest", "exists", f"{repo}:{tag}"],
["podman", "image", "exists", f"{repo}:{tag}"]]
cmds = [["podman", "image", "exists", f"{repo}:{tag}"],
["podman", "manifest", "exists", f"{repo}:{tag}"]]
for cmd in cmds:
cp = runcmd(cmd, check=False)
# The commands returns 0 (exists), 1 (doesn't exist), 125 (other error)