Skip to content

Commit feb6d2e

Browse files
committed
feat: support nydus image format
Signed-off-by: fatelei <[email protected]>
1 parent b0f86df commit feb6d2e

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

go.work.sum

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ github.com/aws/smithy-go v1.23.1/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4p
4444
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
4545
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
4646
github.com/chainguard-dev/clog v1.7.0/go.mod h1:4+WFhRMsGH79etYXY3plYdp+tCz/KCkU8fAr0HoaPvs=
47-
github.com/checkpoint-restore/go-criu/v8 v8.0.0/go.mod h1:GtCbuv5kNUGKXLEhHwURnHwhHf7VApBd4k0+5cqsRmA=
47+
github.com/checkpoint-restore/go-criu/v7 v7.2.0/go.mod h1:u0LCWLg0w4yqqu14aXhiB4YD3a1qd8EcCEg7vda5dwo=
4848
github.com/cilium/ebpf v0.17.3/go.mod h1:G5EDHij8yiLzaqn0WjyfJHvRa+3aDlReIaLVRMvOyJk=
4949
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
5050
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
@@ -153,10 +153,12 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
153153
goa.design/goa/v3 v3.22.6/go.mod h1:rhssEXxox3+sKnYp18hPNFCz65I4hLWHEtJKewoNJWk=
154154
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
155155
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
156+
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54/go.mod h1:hKdjCMrbv9skySur+Nek8Hd0uJ0GuxJIoIX2payrIdQ=
156157
google.golang.org/api v0.254.0/go.mod h1:5BkSURm3D9kAqjGvBNgf0EcbX6Rnrf6UArKkwBzAyqQ=
157158
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
158159
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
159160
sigs.k8s.io/knftables v0.0.18/go.mod h1:f/5ZLKYEUPUhVjUCg6l80ACdL7CIIyeL0DxfgojGRTk=
160161
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
161162
sigs.k8s.io/release-utils v0.12.2/go.mod h1:Ab9Lb/FpGUw4lUXj1QYbUcF2TRzll+GS7Md54W1G7sA=
162163
tags.cncf.io/container-device-interface/specs-go v1.0.0/go.mod h1:u86hoFWqnh3hWz3esofRFKbI261bUlvUfLKGrDhJkgQ=
164+
tags.cncf.io/container-device-interface/specs-go v1.1.0/go.mod h1:u86hoFWqnh3hWz3esofRFKbI261bUlvUfLKGrDhJkgQ=

image/internal/image/oci.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, options *type
290290
case ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc, ociencspec.MediaTypeLayerZstdEnc,
291291
ociencspec.MediaTypeLayerNonDistributableEnc, ociencspec.MediaTypeLayerNonDistributableGzipEnc, ociencspec.MediaTypeLayerNonDistributableZstdEnc:
292292
return nil, fmt.Errorf("during manifest conversion: encrypted layers (%q) are not supported in docker images", layers[idx].MediaType)
293+
case internalManifest.NydusBootstrapLayerMediaType, internalManifest.NydusBlobLayerMediaType:
294+
layers[idx].MediaType = manifest.DockerV2Schema2ForeignLayerMediaType
293295
default:
294296
return nil, fmt.Errorf("Unknown media type during manifest conversion: %q", layers[idx].MediaType)
295297
}

image/internal/manifest/manifest.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const (
3434
DockerV2Schema2ForeignLayerMediaType = "application/vnd.docker.image.rootfs.foreign.diff.tar"
3535
// DockerV2Schema2ForeignLayerMediaType is the MIME type used for gzipped schema 2 foreign layers.
3636
DockerV2Schema2ForeignLayerMediaTypeGzip = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
37+
// NydusBootstrapLayerMediaType is the MIME type used for Nydus bootstrap layers.
38+
NydusBootstrapLayerMediaType = "application/vnd.containers.image.nydus.bootstrap.v1+json"
39+
// NydusBlobLayerMediaType is the MIME type used for Nydus data blob layers.
40+
NydusBlobLayerMediaType = "application/vnd.containers.image.nydus.blob.v1"
3741
)
3842

3943
// GuessMIMEType guesses MIME type of a manifest and returns it _if it is recognized_, or "" if unknown or unrecognized.

image/manifest/oci.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ func SupportedOCI1MediaType(m string) error {
4747
imgspecv1.MediaTypeImageLayerNonDistributable, imgspecv1.MediaTypeImageLayerNonDistributableGzip, imgspecv1.MediaTypeImageLayerNonDistributableZstd, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images.
4848
imgspecv1.MediaTypeImageManifest,
4949
imgspecv1.MediaTypeLayoutHeader,
50-
ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc:
50+
ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc,
51+
manifest.NydusBootstrapLayerMediaType, manifest.NydusBlobLayerMediaType:
5152
return nil
5253
default:
5354
return fmt.Errorf("unsupported OCIv1 media type: %q", m)
@@ -142,10 +143,20 @@ func (m *OCI1) UpdateLayerInfos(layerInfos []types.BlobInfo) error {
142143
}
143144
mimeType = decMimeType
144145
}
145-
mimeType, err := updatedMIMEType(oci1CompressionMIMETypeSets, mimeType, info)
146-
if err != nil {
147-
return fmt.Errorf("preparing updated manifest, layer %q: %w", info.Digest, err)
146+
// Nydus layer types don't support compression/decompression operations
147+
// They should only be preserved as-is
148+
if mimeType == manifest.NydusBootstrapLayerMediaType || mimeType == manifest.NydusBlobLayerMediaType {
149+
if info.CompressionOperation != types.PreserveOriginal {
150+
return fmt.Errorf("preparing updated manifest, layer %q: Nydus layer types (%q) do not support compression or decompression operations", info.Digest, mimeType)
151+
}
152+
} else {
153+
var err error
154+
mimeType, err = updatedMIMEType(oci1CompressionMIMETypeSets, mimeType, info)
155+
if err != nil {
156+
return fmt.Errorf("preparing updated manifest, layer %q: %w", info.Digest, err)
157+
}
148158
}
159+
149160
if info.CryptoOperation == types.Encrypt {
150161
encMediaType, err := getEncryptedMediaType(mimeType)
151162
if err != nil {

0 commit comments

Comments
 (0)