google / google/go-containerregistry

Enhancement: Add indentation to raw manifests

Open
#2,055 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4k
Forks
686
Avg merge
2d 12h
Merged PRs (30d)
26

Description

## Description

Currently the image manifests are generated as json objects without indentation. It would be useful to add the indentation to improve the readability once they are inspected remotely. Moreover, mutating an image manifest that has the indentation, which is a default aspect of images built by tools like `buildkit`, produces a manifest which doesn't have it.

## Example

1. Build a `FROM scratch` image with docker buildkit and push to a local registry.
2. Inspect the manifest with `crane manifest`:
```
crane manifest localhost:5000/simple-manifest:latest

{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"digest": "sha256:ea12cb742e0c435f825fddd7c246ac6773336a62550efd50501500ddf72eb581",
"size": 894
},
"layers": null
}
```
3. Mutate the manifest with `crane mutate`:
```
crane mutate localhost:5000/simple-manifest:latest

2025/02/08 12:46:02 pushed blob: sha256:701db07f8f291e50fbb06b4dd13310acad36c53120adbdf2568bd2009d48a2a3
2025/02/08 12:46:02 localhost:5000/simple-manifest:latest: digest: sha256:3a1223887a4b154965ef2168833b31b52677e230f22627f0d27ba9d1533f5b49 size: 266
localhost:5000/simple-manifest@sha256:3a1223887a4b154965ef2168833b31b52677e230f22627f0d27ba9d1533f5b49
```
4. Inspect the manifest again with `crane manifest`:
```
crane manifest localhost:5000/simple-manifest:latest

{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.v2+json","config":{"mediaType":"application/vnd.docker.container.image.v1+json","size":897,"digest":"sha256:701db07f8f291e50fbb06b4dd13310acad36c53120adbdf2568bd2009d48a2a3"},"layers":null}
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing how `crane mutate` serializes the raw image manifest, then compare that path with the output shown by `crane manifest`. The work is done when mutating an indented manifest preserves readable indentation instead of producing a compact JSON object, while retaining the documented manifest contents.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.