feat(sync): use regclient for sync extension (#2903)

* feat(sync): use regclient for sync extension

replaced containers/image package with regclient/regclient package

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(sync): fixed converting innner docker list mediatype

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* feat(sync): added option to preserve digest

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(sync): added coverage and various fixes

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(metadb): fixed converting manifest list not setting platform and annotations

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(sync): remove read lock on storage, not used concurrently

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* feat(sync): added cache for repo tags

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(sync): fixed Makefile
removed opengpg tag

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

* fix(sync): add test for on demand referrer

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>

---------

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>
This commit is contained in:
peusebiu
2025-04-16 02:58:15 +03:00
committed by GitHub
parent 2592d4c784
commit 0e2aa81439
58 changed files with 2279 additions and 3741 deletions
+24 -9
View File
@@ -34,6 +34,12 @@ func MakeAuthTestServer(serverKey, signAlg string, unauthorizedNamespace string)
signingMethod := jwt.GetSigningMethod(signAlg)
authTestServer := httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
if request.Method != http.MethodGet {
response.WriteHeader(http.StatusMethodNotAllowed)
return
}
var access []api.ResourceAccess
scope := request.URL.Query().Get("scope")
@@ -94,10 +100,21 @@ func MakeAuthTestServerLegacy(serverKey string, unauthorizedNamespace string) *h
}
authTestServer := httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
if request.Method != http.MethodGet {
response.WriteHeader(http.StatusMethodNotAllowed)
return
}
var access []auth.AccessEntry
scope := request.URL.Query().Get("scope")
if scope != "" {
scopes := request.URL.Query()["scope"]
for _, scope := range scopes {
if scope == "" {
continue
}
parts := strings.Split(scope, ":")
name := parts[1]
actions := strings.Split(parts[2], ",")
@@ -106,13 +123,11 @@ func MakeAuthTestServerLegacy(serverKey string, unauthorizedNamespace string) *h
actions = []string{}
}
access = []auth.AccessEntry{
{
Name: name,
Type: "repository",
Actions: actions,
},
}
access = append(access, auth.AccessEntry{
Name: name,
Type: "repository",
Actions: actions,
})
}
token, err := cmTokenGenerator.GenerateToken(access, time.Minute*1)
+1
View File
@@ -532,6 +532,7 @@ func (ib *BaseImageBuilder) Build() Image {
Digest: ib.digestAlgorithm.FromBytes(manifestBlob),
Size: int64(len(manifestBlob)),
Data: manifestBlob,
Platform: &ib.config.Platform,
}
return img
+12 -6
View File
@@ -39,9 +39,12 @@ func (mi *MultiarchImage) DigestStr() string {
func (mi *MultiarchImage) DescriptorRef() *ispec.Descriptor {
return &ispec.Descriptor{
MediaType: mi.IndexDescriptor.MediaType,
Digest: mi.IndexDescriptor.Digest,
Size: mi.IndexDescriptor.Size,
MediaType: mi.IndexDescriptor.MediaType,
Digest: mi.IndexDescriptor.Digest,
Size: mi.IndexDescriptor.Size,
Platform: mi.IndexDescriptor.Platform,
Annotations: mi.IndexDescriptor.Annotations,
ArtifactType: mi.IndexDescriptor.ArtifactType,
}
}
@@ -165,9 +168,12 @@ func (mb *BaseMultiarchBuilder) Build() MultiarchImage {
for i := range manifests {
manifests[i] = ispec.Descriptor{
Digest: mb.images[i].ManifestDescriptor.Digest,
Size: mb.images[i].ManifestDescriptor.Size,
MediaType: ispec.MediaTypeImageManifest,
Digest: mb.images[i].ManifestDescriptor.Digest,
Size: mb.images[i].ManifestDescriptor.Size,
MediaType: ispec.MediaTypeImageManifest,
Platform: mb.images[i].ManifestDescriptor.Platform,
Annotations: mb.images[i].ManifestDescriptor.Annotations,
ArtifactType: mb.images[i].ManifestDescriptor.ArtifactType,
}
}
+4
View File
@@ -22,6 +22,10 @@ var (
)
func UploadImage(img Image, baseURL, repo, ref string) error {
if ref == "" {
ref = img.DigestStr()
}
digestAlgorithm := img.digestAlgorithm
if digestAlgorithm == "" {