2022-04-27 01:00:20 -05:00
|
|
|
//go:build sync
|
|
|
|
// +build sync
|
|
|
|
|
|
|
|
package extensions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
goSync "sync"
|
|
|
|
|
|
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
|
|
"zotregistry.io/zot/pkg/extensions/sync"
|
|
|
|
"zotregistry.io/zot/pkg/log"
|
|
|
|
"zotregistry.io/zot/pkg/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
func EnableSyncExtension(ctx context.Context, config *config.Config, wg *goSync.WaitGroup,
|
|
|
|
storeController storage.StoreController, log log.Logger,
|
|
|
|
) {
|
|
|
|
if config.Extensions.Sync != nil && *config.Extensions.Sync.Enable {
|
|
|
|
if err := sync.Run(ctx, *config.Extensions.Sync, storeController, wg, log); err != nil {
|
|
|
|
log.Error().Err(err).Msg("Error encountered while setting up syncing")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.Info().Msg("Sync registries config not provided or disabled, skipping sync")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-08 03:38:16 -05:00
|
|
|
func SyncOneImage(ctx context.Context, config *config.Config, storeController storage.StoreController,
|
2022-04-27 01:00:20 -05:00
|
|
|
repoName, reference string, isArtifact bool, log log.Logger,
|
|
|
|
) error {
|
|
|
|
log.Info().Msgf("syncing image %s:%s", repoName, reference)
|
|
|
|
|
2022-11-08 03:38:16 -05:00
|
|
|
err := sync.OneImage(ctx, *config.Extensions.Sync, storeController, repoName, reference, isArtifact, log)
|
2022-04-27 01:00:20 -05:00
|
|
|
|
|
|
|
return err
|
|
|
|
}
|