Skip to content

Commit 2fc9d58

Browse files
Merge pull request containers#6284 from aeijdenberg/ociarchivefailure
fix(build): make --tag oci-archive:xxx.tar work with simple images
2 parents 991a731 + 8fa05df commit 2fc9d58

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

imagebuildah/stage_executor.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2118,12 +2118,19 @@ func (s *StageExecutor) tagExistingImage(ctx context.Context, cacheID, output st
21182118
return "", nil, fmt.Errorf("getting source imageReference for %q: %w", cacheID, err)
21192119
}
21202120
options := cp.Options{
2121-
RemoveSignatures: true, // more like "ignore signatures", since they don't get removed when src and dest are the same image
2121+
RemoveSignatures: true, // more like "ignore signatures", since they don't get removed when src and dest are the same image
2122+
DestinationTimestamp: s.executor.timestamp,
21222123
}
21232124
manifestBytes, err := cp.Image(ctx, policyContext, dest, src, &options)
21242125
if err != nil {
21252126
return "", nil, fmt.Errorf("copying image %q: %w", cacheID, err)
21262127
}
2128+
2129+
// If the destination isn't container storage, then we're done and can return early
2130+
if dest.Transport().Name() != is.Transport.Name() {
2131+
return cacheID, nil, nil
2132+
}
2133+
21272134
manifestDigest, err := manifest.Digest(manifestBytes)
21282135
if err != nil {
21292136
return "", nil, fmt.Errorf("computing digest of manifest for image %q: %w", cacheID, err)

tests/bud.bats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8074,6 +8074,17 @@ _EOF
80748074
diff "${outpath}.b" "${outpath}.c"
80758075
}
80768076

8077+
@test "build-with-timestamp-applies-to-oci-archive-with-base" {
8078+
local outpath="${TEST_SCRATCH_DIR}/timestamp-oci.tar"
8079+
8080+
run_buildah build -f <(echo 'FROM busybox') --tag=oci-archive:${outpath}.a --timestamp 0
8081+
sleep 1.1 # sleep at least 1 second, so that timestamps are incremented
8082+
run_buildah build -f <(echo 'FROM busybox') --tag=oci-archive:${outpath}.b --timestamp 0
8083+
8084+
# should be the same
8085+
diff "${outpath}.a" "${outpath}.b"
8086+
}
8087+
80778088
@test "bud-source-date-epoch-arg" {
80788089
_prefetch busybox
80798090
local timestamp=60

0 commit comments

Comments
 (0)