google / google/go-containerregistry

FR: `crane append` can omit files if they already exist in the base

Open
#1,328 1 comment 1 reaction 0 assignees View on GitHub
lifecycle/frozen
Dominant language
Go
Stars
4k
Forks
686
Avg merge
2d 12h
Merged PRs (30d)
26

Description

@vdemeester asked about this

`crane append` currently just takes the provided tar file(s), and slaps it on top of the base image. This works fine, but it means if you repeatedly `crane append` the same (or only slightly different) tar onto the same base, it ends up with a bunch of duplicated layer data.

It could be cool if `crane append` and/or [`crane.Append`](https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane#Append) or even-lower-level [`mutate.Append`](https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/mutate#Append) took an option to inspect the flattened base image and exclude any duplicate files (same path, same contents) in the new layer(s). If there are no new contents at all, `crane append` would be a no-op.

Contributor guide

Open the contributing guide

Research direction

Start by reading the named crane append command and the crane.Append and mutate.Append entry points. Determine how a flattened base image can be compared with incoming tar files and how an option should control duplicate exclusion. Done means repeated appends omit files with identical paths and contents, and an append with no new contents is a no-op.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.