Open
Conversation
added 5 commits
April 26, 2025 19:09
Build for multiple platforms. Use a manifest in all situations because buildah can not create a manifest when a tag already exists.
Manifests for buildah and podman have no digest. Buildah pushs the manifest to all tags and TaggedImage must ignore the incomplete URL.
added 5 commits
May 2, 2025 11:48
The manifest digest is written to a temporary file with the option --digestfile. Push only to a random tag and let kbld create the other tags.
added 6 commits
May 11, 2025 21:29
…nation Use the destination name for local storage if available. The destination name use a special random tag.
Generation logs are printed in direct using stderr. Flushes mid-sentence are not well rendered through logger.
Using the same manifest name accumulates images. The local manifest needs a random name.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Buildah-based image build/publish support to kbld, integrating it as an additional builder option alongside existing Docker/buildx/ko/pack/etc flows.
Changes:
- Introduces a new
buildah:source configuration (SourceBuildahOpts) and a Buildah builder implementation that builds viabuildah build --manifestand pushes viabuildah manifest push. - Wires Buildah into the image build factory and build dispatch logic (
Factory/BuiltImage). - Updates tagging behavior to only apply
ImageDestinations.tagswhen the produced image URL is digest-qualified, and adds an e2e test covering build+push.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/kbld/builder/buildah/buildah.go |
New Buildah builder implementation for build + manifest push + digest retrieval. |
pkg/kbld/config/config_buildah.go |
New config types + arg rendering for Buildah builds. |
pkg/kbld/config/config.go |
Adds Buildah to config.Source to enable buildah: in Sources. |
pkg/kbld/image/built.go |
Routes builds through Buildah when configured. |
pkg/kbld/image/factory.go |
Instantiates Buildah builder and passes it into BuiltImage. |
pkg/kbld/image/tagged.go |
Applies destination tags only when URL includes a digest (@...). |
test/e2e/build_buildah_test.go |
New e2e test for Buildah build+push and digest-based output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+2
| package buildah | ||
|
|
Member
There was a problem hiding this comment.
It should be:
// Copyright 2026 The Carvel Authors.
// SPDX-License-Identifier: Apache-2.0
Comment on lines
+89
to
+93
| cmd := exec.Command("buildah", cmdArgs...) | ||
| cmd.Dir = directory | ||
| cmd.Stdout = prefixedLogger | ||
| cmd.Stderr = os.Stderr | ||
|
|
Comment on lines
+28
to
+29
| // Provide explicit directory check error message because otherwise docker CLI | ||
| // outputs confusing msg 'error: fork/exec /usr/local/bin/docker: not a directory' |
Comment on lines
+1
to
+3
| package e2e | ||
|
|
||
| import ( |
Comment on lines
+101
to
+109
| pushLogger := b.logger.NewPrefixedWriter(image + " push | ") | ||
| remoteName := remoteImageName(image, imgDst) | ||
| digest, pushErr := BuildahPush(localName, remoteName, pushLogger) | ||
| if pushErr != nil { | ||
| return "", pushErr | ||
| } | ||
| remoteName = remoteName + "@" + digest | ||
| prefixedLogger.WriteStr("Image build : " + remoteName) | ||
| return remoteName, nil |
Comment on lines
+127
to
+142
| // !!! with --digestfile, buildah will not return an error if an authentication is required. | ||
| log.WriteStr("=> buildah manifest push --all --digestfile=" + digestFile.Name() + " " + src + " docker://" + dest) | ||
| pushCommand := exec.Command("buildah", "manifest", "push", "--all", "--digestfile="+digestFile.Name(), src, "docker://"+dest) | ||
| pushCommand.Stdout = log | ||
| pushCommand.Stderr = log | ||
| pushErr := pushCommand.Run() | ||
| if pushErr != nil { | ||
| return "", fmt.Errorf("error pushing to %q (check if you are authenticated) : %w", dest, pushErr) | ||
| } | ||
|
|
||
| digest := make([]byte, 64+7) | ||
| digestLen, readErr := digestFile.Read(digest) | ||
| if readErr != nil { | ||
| return "", fmt.Errorf("cannot read digest in file %q (check if you are authenticated) : %w", digestFile.Name(), readErr) | ||
| } | ||
| return string(digest[0:digestLen]), nil |
Comment on lines
+31
to
33
| if len(i.imgDst.Tags) > 0 && strings.Contains(url, "@") { | ||
| // Configure new tags only if a digest is known | ||
| dstRef, err := regname.NewDigest(url, regname.WeakValidation) |
| expectedOut := env.WithRegistries(`--- | ||
| kind: Object | ||
| spec: | ||
| - image: index.docker.io/*username*/kbld-e2e-tests-build:latest@SHA256-REPLACED1 |
Comment on lines
+35
to
+37
| for arg, value := range opts.BuildArgs { | ||
| args = append(args, "--build-arg="+arg+"="+value) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for buildah to create and publish images.
The
buildah buildcommand with the--manifestoption is used to build an image.The
buildah manifest pushcommand sends the images to a remote registry and retrieve the digest (use a random tag like docker).Options example in sources:
The user can use rawOptions to add arguments like
--layers,--jobs=0or--cache-from. None of them is activated by default.