mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 11:37:56 +08:00
2402296e9a
* fix: migrate to Go module v2 for proper semantic versioning This change updates the module path from 'zotregistry.dev/zot' to 'zotregistry.dev/zot/v2' to comply with Go's semantic versioning rules. According to Go's module versioning requirements, major version v2+ must include the major version in the module path. The current module path 'zotregistry.dev/zot' only supports v0.x.x and v1.x.x versions, making existing v2.x.x tags (like v2.1.8) unusable. Changes: - Updated go.mod module path to zotregistry.dev/zot/v2 - Updated all internal import paths across 280+ Go source files - Updated configuration files (golangcilint.yaml, gqlgen.yml) - Updated README.md Go reference badge This fix enables proper use of existing v2.x.x Git tags and allows external packages to import zot v2+ versions without compatibility errors. Resolves: Go module import compatibility for v2+ versions Fixes: #3071 Signed-off-by: Luca Muscariello <muscariello@ieee.org> * fix: regenerate GraphQL files with updated v2 import paths The gqlgen tool needs to regenerate the GraphQL schema files after the module path change to use the new v2 imports. Signed-off-by: Luca Muscariello <muscariello@ieee.org> --------- Signed-off-by: Luca Muscariello <muscariello@ieee.org>
87 lines
2.4 KiB
Go
87 lines
2.4 KiB
Go
//go:build sync
|
|
// +build sync
|
|
|
|
package server
|
|
|
|
import (
|
|
"path"
|
|
|
|
"zotregistry.dev/zot/v2/pkg/api/config"
|
|
syncconf "zotregistry.dev/zot/v2/pkg/extensions/config/sync"
|
|
"zotregistry.dev/zot/v2/pkg/extensions/sync"
|
|
zlog "zotregistry.dev/zot/v2/pkg/log"
|
|
)
|
|
|
|
func validateRetentionSyncOverlaps(config *config.Config, content syncconf.Content, urls []string, log zlog.Logger) {
|
|
cm := sync.NewContentManager([]syncconf.Content{content}, log)
|
|
|
|
prefix := content.Prefix
|
|
if content.Destination != "" {
|
|
prefix = cm.GetRepoDestination(content.Prefix)
|
|
}
|
|
|
|
repoPolicy := getRepoPolicyByPrefix(config, prefix)
|
|
if repoPolicy == nil {
|
|
return
|
|
}
|
|
|
|
if content.Tags != nil && content.Tags.Regex != nil {
|
|
areTagsRetained := false
|
|
|
|
for _, tagPolicy := range repoPolicy.KeepTags {
|
|
for _, tagRegex := range tagPolicy.Patterns {
|
|
if tagRegex == *content.Tags.Regex {
|
|
areTagsRetained = true
|
|
}
|
|
}
|
|
}
|
|
|
|
if !areTagsRetained {
|
|
log.Warn().Str("repositories pattern", prefix).
|
|
Str("tags regex", *content.Tags.Regex).
|
|
Interface("sync urls", urls).
|
|
Interface("overlapping sync content", content).
|
|
Interface("overlapping repo policy", repoPolicy).
|
|
Msgf("retention policy can overlap with the sync config, "+
|
|
"make sure retention doesn't remove syncing images with next tag regex: %s", *content.Tags.Regex)
|
|
}
|
|
} else {
|
|
log.Warn().Str("repositories pattern", prefix).
|
|
Interface("sync urls", urls).
|
|
Interface("overlapping sync content", content).
|
|
Interface("overlapping repo policy", repoPolicy).
|
|
Msg("retention policy can overlap with the sync config, make sure retention doesn't remove syncing images")
|
|
}
|
|
}
|
|
|
|
func getRepoPolicyByPrefixFromStorageConfig(config config.StorageConfig, subpath string, prefix string,
|
|
) *config.RetentionPolicy {
|
|
for _, repoPolicy := range config.Retention.Policies {
|
|
for _, repo := range repoPolicy.Repositories {
|
|
if subpath != "" {
|
|
repo = path.Join(subpath, repo)[1:] // remove startin '/'
|
|
}
|
|
|
|
if repo == prefix {
|
|
return &repoPolicy
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func getRepoPolicyByPrefix(config *config.Config, prefix string) *config.RetentionPolicy {
|
|
if repoPolicy := getRepoPolicyByPrefixFromStorageConfig(config.Storage.StorageConfig, "", prefix); repoPolicy != nil {
|
|
return repoPolicy
|
|
}
|
|
|
|
for subpath, subpathConfig := range config.Storage.SubPaths {
|
|
if repoPolicy := getRepoPolicyByPrefixFromStorageConfig(subpathConfig, subpath, prefix); repoPolicy != nil {
|
|
return repoPolicy
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|