working commit

This commit is contained in:
2026-02-05 17:13:35 +02:00
parent e81037d75f
commit 8dce641498
6 changed files with 170 additions and 64 deletions
+50 -3
View File
@@ -11,8 +11,6 @@ import (
"mstore/app/descr"
"mstore/pkg/auxoci"
ocidigest "github.com/opencontainers/go-digest"
)
const (
@@ -69,7 +67,7 @@ func (oper *Operator) ManifestExists(ctx context.Context, params *ManifestExists
}
}
digest := ocidigest.SHA256.FromString(manifest.Payload)
digest := auxoci.SHA256DigestFromString(manifest.Payload)
payloadSize := len(manifest.Payload)
res.ContentLength = strconv.FormatInt(int64(payloadSize), 10)
res.ContentType = manifest.ContentType
@@ -227,3 +225,52 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
return res, http.StatusCreated, err
}
type GetManifestParams struct {
Name string
Reference string
}
type GetManifestResult struct {
ContentLength string
ContentType string
DockerContentDigest string
Payload string
}
func (oper *Operator) GetManifest(ctx context.Context, params *GetManifestParams) (*GetManifestResult, int, error) {
var err error
res := &GetManifestResult{}
oper.logg.Debugf("Get manifest %s:%s", params.Name, params.Reference)
manifestDescr := descr.Manifest{}
var exists bool
if stringLikeSHADigest(params.Reference) {
digest := normalizeSHADigest(params.Reference)
oper.logg.Debugf("Get manifest %s with digest %s", params.Name, params.Reference)
exists, manifestDescr, err = oper.mdb.GetManifestByDigest(ctx, params.Name, digest)
if err != nil {
return res, http.StatusInternalServerError, err
}
if !exists {
return res, http.StatusNotFound, err
}
} else {
oper.logg.Debugf("Get manifest %s with tag %s", params.Name, params.Reference)
exists, manifestDescr, err = oper.mdb.GetManifestByReference(ctx, params.Name, params.Reference)
if err != nil {
return res, http.StatusInternalServerError, err
}
if !exists {
return res, http.StatusNotFound, err
}
}
manifestDigest := auxoci.SHA256DigestFromString(manifestDescr.Payload)
res.DockerContentDigest = manifestDigest.String()
res.ContentLength = strconv.FormatInt(int64(len(manifestDescr.Payload)), 10)
res.ContentType = manifestDescr.ContentType
res.Payload = manifestDescr.Payload
return res, http.StatusOK, err
}