-
Notifications
You must be signed in to change notification settings - Fork 70
feat(image): add WASM OCI image support #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,7 @@ func (m *manifestOCI1) ConfigBlob(ctx context.Context) ([]byte, error) { | |
| // layers in the resulting configuration isn't guaranteed to be returned to due how | ||
| // old image manifests work (docker v2s1 especially). | ||
| func (m *manifestOCI1) OCIConfig(ctx context.Context) (*imgspecv1.Image, error) { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.m.Config.MediaType != internalManifest.WasmConfigMediaType { | ||
| return nil, internalManifest.NewNonImageArtifactError(&m.m.Manifest) | ||
| } | ||
|
|
||
|
|
@@ -244,7 +244,7 @@ func (m *manifestOCI1) layerEditsOfOCIOnlyFeatures(options *types.ManifestUpdate | |
| // value. | ||
| // This does not change the state of the original manifestOCI1 object. | ||
| func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, options *types.ManifestUpdateOptions) (*manifestSchema2, error) { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.m.Config.MediaType != internalManifest.WasmConfigMediaType { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would that work??! |
||
| return nil, internalManifest.NewNonImageArtifactError(&m.m.Manifest) | ||
| } | ||
|
|
||
|
|
@@ -290,6 +290,9 @@ func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, options *type | |
| case ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc, ociencspec.MediaTypeLayerZstdEnc, | ||
| ociencspec.MediaTypeLayerNonDistributableEnc, ociencspec.MediaTypeLayerNonDistributableGzipEnc, ociencspec.MediaTypeLayerNonDistributableZstdEnc: | ||
| return nil, fmt.Errorf("during manifest conversion: encrypted layers (%q) are not supported in docker images", layers[idx].MediaType) | ||
| case internalManifest.WasmContentLayerMediaType, internalManifest.WasmContentLayerMediaType + "+gzip", internalManifest.WasmContentLayerMediaType + "+zstd", | ||
| internalManifest.WasmContentLayerMediaType + "+encrypted", internalManifest.WasmContentLayerMediaType + "+gzip+encrypted", internalManifest.WasmContentLayerMediaType + "+zstd+encrypted": | ||
| return nil, fmt.Errorf("during manifest conversion: WASM layers (%q) are not supported in docker images", layers[idx].MediaType) | ||
| default: | ||
| return nil, fmt.Errorf("Unknown media type during manifest conversion: %q", layers[idx].MediaType) | ||
| } | ||
|
|
@@ -306,7 +309,7 @@ func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, options *type | |
| // value. | ||
| // This does not change the state of the original manifestOCI1 object. | ||
| func (m *manifestOCI1) convertToManifestSchema1(ctx context.Context, options *types.ManifestUpdateOptions) (genericManifest, error) { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| if m.m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.m.Config.MediaType != internalManifest.WasmConfigMediaType { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| return nil, internalManifest.NewNonImageArtifactError(&m.m.Manifest) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,10 @@ func SupportedOCI1MediaType(m string) error { | |
| imgspecv1.MediaTypeImageLayerNonDistributable, imgspecv1.MediaTypeImageLayerNonDistributableGzip, imgspecv1.MediaTypeImageLayerNonDistributableZstd, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. | ||
| imgspecv1.MediaTypeImageManifest, | ||
| imgspecv1.MediaTypeLayoutHeader, | ||
| ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc: | ||
| ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is deprecated and has no known users, so I don’t see much point in extending it. |
||
| manifest.WasmContentLayerMediaType, manifest.WasmContentLayerMediaType + "+gzip", manifest.WasmContentLayerMediaType + "+zstd", | ||
| manifest.WasmContentLayerMediaType + "+encrypted", manifest.WasmContentLayerMediaType + "+gzip+encrypted", manifest.WasmContentLayerMediaType + "+zstd+encrypted", | ||
| manifest.WasmConfigMediaType: | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("unsupported OCIv1 media type: %q", m) | ||
|
|
@@ -116,6 +119,11 @@ var oci1CompressionMIMETypeSets = []compressionMIMETypeSet{ | |
| compressiontypes.GzipAlgorithmName: imgspecv1.MediaTypeImageLayerGzip, | ||
| compressiontypes.ZstdAlgorithmName: imgspecv1.MediaTypeImageLayerZstd, | ||
| }, | ||
| { | ||
| mtsUncompressed: manifest.WasmContentLayerMediaType, | ||
| compressiontypes.GzipAlgorithmName: manifest.WasmContentLayerMediaType + "+gzip", | ||
| compressiontypes.ZstdAlgorithmName: manifest.WasmContentLayerMediaType + "+zstd", | ||
| }, | ||
| } | ||
|
|
||
| // UpdateLayerInfos replaces the original layers with the specified BlobInfos (size+digest+urls+mediatype), in order (the root layer first, and then successive layered layers) | ||
|
|
@@ -173,7 +181,8 @@ func getEncryptedMediaType(mediatype string) (string, error) { | |
| unsuffixedMediatype := parts[0] | ||
| switch unsuffixedMediatype { | ||
| case DockerV2Schema2LayerMediaType, imgspecv1.MediaTypeImageLayer, | ||
| imgspecv1.MediaTypeImageLayerNonDistributable: //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. | ||
| imgspecv1.MediaTypeImageLayerNonDistributable, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. | ||
| manifest.WasmContentLayerMediaType: | ||
| return mediatype + "+encrypted", nil | ||
| } | ||
|
|
||
|
|
@@ -199,11 +208,11 @@ func (m *OCI1) Serialize() ([]byte, error) { | |
|
|
||
| // Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration. | ||
| func (m *OCI1) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*types.ImageInspectInfo, error) { | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| // We could return at least the layers, but that’s already available in a better format via types.Image.LayerInfos. | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.Config.MediaType != manifest.WasmConfigMediaType { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again |
||
| // We could return at least the layers, but that's already available in a better format via types.Image.LayerInfos. | ||
| // Most software calling this without human intervention is going to expect the values to be realistic and relevant, | ||
| // and is probably better served by failing; we can always re-visit that later if we fail now, but | ||
| // if we started returning some data for OCI artifacts now, we couldn’t start failing in this function later. | ||
| // if we started returning some data for OCI artifacts now, we couldn't start failing in this function later. | ||
| return nil, manifest.NewNonImageArtifactError(&m.Manifest) | ||
| } | ||
|
|
||
|
|
@@ -253,8 +262,8 @@ func (m *OCI1) ImageID(diffIDs []digest.Digest) (string, error) { | |
| // gives us the option to not fail, and return some value, in the future, | ||
| // without committing to that approach now. | ||
| // (The only known caller of ImageID is storage/storageImageDestination.computeID, | ||
| // which can’t work with non-image artifacts.) | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| // which can't work with non-image artifacts.) | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.Config.MediaType != manifest.WasmConfigMediaType { | ||
| return "", manifest.NewNonImageArtifactError(&m.Manifest) | ||
| } | ||
|
|
||
|
|
@@ -269,7 +278,7 @@ func (m *OCI1) ImageID(diffIDs []digest.Digest) (string, error) { | |
| // NOTE: Even if this returns true, the relevant format might not accept all compression algorithms; the set of accepted | ||
| // algorithms depends not on the current format, but possibly on the target of a conversion. | ||
| func (m *OCI1) CanChangeLayerCompression(mimeType string) bool { | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig { | ||
| if m.Config.MediaType != imgspecv1.MediaTypeImageConfig && m.Config.MediaType != manifest.WasmConfigMediaType { | ||
| return false | ||
| } | ||
| return compressionVariantsRecognizeMIMEType(oci1CompressionMIMETypeSets, mimeType) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS the two objects are not interchangeable and it makes no sense to parse the WASM one as an OCI one.