app/imageoper: index only for OCI manifests
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||||
|
*
|
||||||
|
* This work is published and licensed under a Creative Commons
|
||||||
|
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||||
|
*
|
||||||
|
* Distribution of this work is permitted, but commercial use and
|
||||||
|
* modifications are strictly prohibited.
|
||||||
|
*/
|
||||||
|
package imageoper
|
||||||
|
|
||||||
|
const (
|
||||||
|
ddmMediaType = "application/vnd.docker.distribution.manifest.v2+json"
|
||||||
|
oimMediaType = "application/vnd.oci.image.manifest.v1+json"
|
||||||
|
oiiMediaType = "application/vnd.oci.image.index.v1+json"
|
||||||
|
|
||||||
|
XXXoicMediaType = "application/vnd.oci.image.config.v1+json"
|
||||||
|
XXXdciMediaType = "application/vnd.docker.container.image.v1+json"
|
||||||
|
)
|
||||||
@@ -21,11 +21,6 @@ import (
|
|||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
oiiMediaType = "application/vnd.oci.image.index.v1+json"
|
|
||||||
oimMediaType = "application/vnd.oci.image.manifest.v1+json"
|
|
||||||
)
|
|
||||||
|
|
||||||
func indexFromManigestDescrs(mandescrs []descr.Manifest) (ocispec.Index, []byte, error) {
|
func indexFromManigestDescrs(mandescrs []descr.Manifest) (ocispec.Index, []byte, error) {
|
||||||
var err error
|
var err error
|
||||||
var indexdata []byte
|
var indexdata []byte
|
||||||
@@ -37,6 +32,10 @@ func indexFromManigestDescrs(mandescrs []descr.Manifest) (ocispec.Index, []byte,
|
|||||||
for _, mandescr := range mandescrs {
|
for _, mandescr := range mandescrs {
|
||||||
var man ocispec.Manifest
|
var man ocispec.Manifest
|
||||||
|
|
||||||
|
if mandescr.ContentType != oimMediaType && mandescr.ContentType != ddmMediaType {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
man.Subject = &ocispec.Descriptor{}
|
man.Subject = &ocispec.Descriptor{}
|
||||||
man.Subject.Platform = &ocispec.Platform{}
|
man.Subject.Platform = &ocispec.Platform{}
|
||||||
man.Config = ocispec.Descriptor{}
|
man.Config = ocispec.Descriptor{}
|
||||||
|
|||||||
@@ -33,14 +33,6 @@ type PutManifestResult struct {
|
|||||||
Location string
|
Location string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
ddmMimeType = "application/vnd.docker.distribution.manifest.v2+json"
|
|
||||||
oimMimeType = "application/vnd.oci.image.manifest.v1+json"
|
|
||||||
|
|
||||||
XXXoicMimeType = "application/vnd.oci.image.config.v1+json"
|
|
||||||
XXXdciMimeType = "application/vnd.docker.container.image.v1+json"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO: lock for the name-reference or simular?
|
// TODO: lock for the name-reference or simular?
|
||||||
func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams) (*PutManifestResult, int, error) {
|
func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams) (*PutManifestResult, int, error) {
|
||||||
var err error
|
var err error
|
||||||
@@ -55,7 +47,7 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
|||||||
return res, http.StatusBadRequest, err
|
return res, http.StatusBadRequest, err
|
||||||
}
|
}
|
||||||
// Check Content-Type
|
// Check Content-Type
|
||||||
if params.ContentType != oimMimeType && params.ContentType != ddmMimeType {
|
if params.ContentType != oimMediaType && params.ContentType != ddmMediaType {
|
||||||
err = fmt.Errorf("Unknown or empty Content-Type: %s", params.ContentType)
|
err = fmt.Errorf("Unknown or empty Content-Type: %s", params.ContentType)
|
||||||
return res, http.StatusNotFound, err
|
return res, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user