0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-02-17 23:45:36 -05:00

feat(sync): onDemand check for updated manifest (#1190)

Signed-off-by: Amit Marcus <marxus@gmail.com>
This commit is contained in:
Amit Marcus 2023-02-13 20:33:48 +02:00 committed by GitHub
parent c0aaca8ed1
commit 2377d62344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1635,30 +1635,21 @@ func (rh *RouteHandler) getImageStore(name string) storage.ImageStore {
func getImageManifest(ctx context.Context, routeHandler *RouteHandler, imgStore storage.ImageStore, name, func getImageManifest(ctx context.Context, routeHandler *RouteHandler, imgStore storage.ImageStore, name,
reference string, reference string,
) ([]byte, godigest.Digest, string, error) { ) ([]byte, godigest.Digest, string, error) {
content, digest, mediaType, err := imgStore.GetImageManifest(name, reference) if routeHandler.c.Config.Extensions != nil &&
if err != nil { routeHandler.c.Config.Extensions.Sync != nil &&
if errors.Is(err, zerr.ErrRepoNotFound) || errors.Is(err, zerr.ErrManifestNotFound) { *routeHandler.c.Config.Extensions.Sync.Enable {
if routeHandler.c.Config.Extensions != nil && routeHandler.c.Log.Info().Msgf("trying to get updated image %s:%s by syncing on demand",
routeHandler.c.Config.Extensions.Sync != nil && name, reference)
*routeHandler.c.Config.Extensions.Sync.Enable {
routeHandler.c.Log.Info().Msgf("image not found, trying to get image %s:%s by syncing on demand",
name, reference)
errSync := ext.SyncOneImage(ctx, routeHandler.c.Config, routeHandler.c.StoreController, errSync := ext.SyncOneImage(ctx, routeHandler.c.Config, routeHandler.c.StoreController,
name, reference, "", routeHandler.c.Log) name, reference, "", routeHandler.c.Log)
if errSync != nil { if errSync != nil {
routeHandler.c.Log.Err(errSync).Msgf("error encounter while syncing image %s:%s", routeHandler.c.Log.Err(errSync).Msgf("error encounter while syncing image %s:%s",
name, reference) name, reference)
} else {
content, digest, mediaType, err = imgStore.GetImageManifest(name, reference)
}
}
} else {
return []byte{}, "", "", err
} }
} }
return content, digest, mediaType, err return imgStore.GetImageManifest(name, reference)
} }
// will sync referrers on demand if they are not found, in case sync extensions is enabled. // will sync referrers on demand if they are not found, in case sync extensions is enabled.