Skip to content

Commit f94caad

Browse files
authored
Merge pull request #339 from wking/should-canonical-json
canonicalization: Add recommendations for canonicalization
2 parents cfac9c9 + 1685bae commit f94caad

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ DOC_FILES := \
3030
layer.md \
3131
config.md \
3232
manifest.md \
33-
manifest-list.md
33+
manifest-list.md \
34+
canonicalization.md
3435

3536
FIGURE_FILES := \
3637
img/media-types.png

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The OCI Image Format project creates and maintains the software shipping contain
1414
- [Image Configuration](config.md)
1515
- [Image Manifest](manifest.md)
1616
- [Image Manifest List](manifest-list.md)
17+
- [Canonicalization](canonicalization.md)
1718

1819
## Overview
1920

canonicalization.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Canonicalization
2+
3+
OCI Images [are](descriptor.md) [content-addressable](image-layout.md).
4+
One benefit of content-addressable storage is easy deduplication.
5+
Many images might depend on a particular [layer](layer.md), but there will only be one blob in the [store](image-layout.md).
6+
With a different serialization, that same semantic layer would have a different hash, and if both versions of the layer are referenced there will be two blobs with the same semantic content.
7+
To allow efficient storage, implementations serializing content for blobs SHOULD use a canonical serialization.
8+
This increases the chance that different implementations can push the same semantic content to the store without creating redundant blobs.
9+
10+
## JSON
11+
12+
[JSON][] content SHOULD be serialized as [canonical JSON][canonical-json].
13+
Of the [OCI Image Format Specification media types](media-types.md), all the types ending in `+json` contain JSON content.
14+
Implementations:
15+
16+
* [Go][]: [github.com/docker/go][], which claims to implement [canonical JSON][canonical-json] except for Unicode normalization.
17+
18+
[canonical-json]: http://wiki.laptop.org/go/Canonical_JSON
19+
[github.com/docker/go]: https://github.com/docker/go/
20+
[Go]: https://golang.org/
21+
[JSON]: http://json.org/

0 commit comments

Comments
 (0)