working commit
This commit is contained in:
@@ -22,11 +22,6 @@ import (
|
||||
"mstore/pkg/auxoci"
|
||||
)
|
||||
|
||||
const (
|
||||
ddmMimeType = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
oimMimeType = "application/vnd.oci.image.manifest.v1+json"
|
||||
)
|
||||
|
||||
type ManifestExistsParams struct {
|
||||
Name string
|
||||
Reference string
|
||||
@@ -93,6 +88,14 @@ type PutManifestResult struct {
|
||||
Location string
|
||||
}
|
||||
|
||||
const (
|
||||
ddmMimeType = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
oimMimeType = "application/vnd.oci.image.manifest.v1+json"
|
||||
|
||||
oicMimeType = "application/vnd.oci.image.config.v1+json"
|
||||
dciMimeType = "application/vnd.docker.container.image.v1+json"
|
||||
)
|
||||
|
||||
// TODO: lock for the name-reference or simular?
|
||||
func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams) (*PutManifestResult, int, error) {
|
||||
var err error
|
||||
@@ -107,7 +110,12 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
return res, http.StatusBadRequest, err
|
||||
}
|
||||
// Check Content-Type
|
||||
if params.ContentType != oimMimeType {
|
||||
var mimeIsAcceptably bool
|
||||
mimeIsAcceptably = mimeIsAcceptably || params.ContentType == oimMimeType
|
||||
mimeIsAcceptably = mimeIsAcceptably || params.ContentType == ddmMimeType
|
||||
mimeIsAcceptably = mimeIsAcceptably || params.ContentType == oicMimeType
|
||||
mimeIsAcceptably = mimeIsAcceptably || params.ContentType == dciMimeType
|
||||
if !mimeIsAcceptably {
|
||||
err = fmt.Errorf("Unknown or empty Content-Type: %s", params.ContentType)
|
||||
return res, http.StatusNotFound, err
|
||||
}
|
||||
@@ -143,6 +151,14 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
code := http.StatusRequestEntityTooLarge
|
||||
return res, code, err
|
||||
}
|
||||
|
||||
// Check point
|
||||
oper.logg.Debugf("=== Incoming manifest type: %s", params.ContentType)
|
||||
oper.logg.Debugf("=== Incoming manifest body: %s", string(incomingManifestBytes))
|
||||
if params.ContentType == oicMimeType || params.ContentType == dciMimeType {
|
||||
return res, http.StatusOK, err
|
||||
}
|
||||
|
||||
incomingManifest, err := auxoci.ParseOCIManifest(incomingManifestBytes)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Parsing OCI manifest error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user