mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
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:
@@ -987,11 +987,11 @@ func runDisplayIndexTests(baseURL string) {
|
||||
actual := strings.TrimSpace(str)
|
||||
// Actual cli output should be something similar to (order of images may differ):
|
||||
// REPOSITORY TAG OS/ARCH DIGEST SIGNED SIZE
|
||||
// repo multi-arch * 4780eafe false 1.5kB
|
||||
// repo multi-arch * d3818454 false 1.7kB
|
||||
// linux/amd64 02e0ac42 false 644B
|
||||
// windows/arm64/v6 5e09b7f9 false 444B
|
||||
So(actual, ShouldContainSubstring, "REPOSITORY TAG OS/ARCH DIGEST SIGNED SIZE")
|
||||
So(actual, ShouldContainSubstring, "repo multi-arch * 4780eafe false 1.5kB ")
|
||||
So(actual, ShouldContainSubstring, "repo multi-arch * d3818454 false 1.7kB ")
|
||||
So(actual, ShouldContainSubstring, "linux/amd64 02e0ac42 false 644B ")
|
||||
So(actual, ShouldContainSubstring, "windows/arm64/v6 5e09b7f9 false 506B")
|
||||
})
|
||||
@@ -1009,14 +1009,14 @@ func runDisplayIndexTests(baseURL string) {
|
||||
actual := strings.TrimSpace(str)
|
||||
// Actual cli output should be something similar to (order of images may differ):
|
||||
// REPOSITORY TAG OS/ARCH DIGEST CONFIG SIGNED LAYERS SIZE
|
||||
// repo multi-arch * 4780eafe false 1.5kB
|
||||
// repo multi-arch * d3818454 false 1.7kB
|
||||
// linux/amd64 02e0ac42 58cc9abe false 644B
|
||||
// cbb5b121 4B
|
||||
// a00291e8 4B
|
||||
// windows/arm64/v6 5e09b7f9 5132a1cd false 506B
|
||||
// 7d08ce29 4B
|
||||
So(actual, ShouldContainSubstring, "REPOSITORY TAG OS/ARCH DIGEST CONFIG SIGNED LAYERS SIZE")
|
||||
So(actual, ShouldContainSubstring, "repo multi-arch * 4780eafe false 1.5kB")
|
||||
So(actual, ShouldContainSubstring, "repo multi-arch * d3818454 false 1.7kB")
|
||||
So(actual, ShouldContainSubstring, "linux/amd64 02e0ac42 58cc9abe false 644B")
|
||||
So(actual, ShouldContainSubstring, "cbb5b121 4B")
|
||||
So(actual, ShouldContainSubstring, "a00291e8 4B")
|
||||
|
||||
+12
-3
@@ -1121,12 +1121,21 @@ func validateGCRules(retention config.ImageRetention, log zlog.Logger) error {
|
||||
func validateSync(config *config.Config, log zlog.Logger) error {
|
||||
// check glob patterns in sync config are compilable
|
||||
if config.Extensions != nil && config.Extensions.Sync != nil {
|
||||
for id, regCfg := range config.Extensions.Sync.Registries {
|
||||
for regID, regCfg := range config.Extensions.Sync.Registries {
|
||||
// check retry options are configured for sync
|
||||
if regCfg.MaxRetries != nil && regCfg.RetryDelay == nil {
|
||||
msg := "retryDelay is required when using maxRetries"
|
||||
log.Error().Err(zerr.ErrBadConfig).Int("id", id).Interface("extensions.sync.registries[id]",
|
||||
config.Extensions.Sync.Registries[id]).Msg(msg)
|
||||
log.Error().Err(zerr.ErrBadConfig).Int("id", regID).Interface("extensions.sync.registries[id]",
|
||||
config.Extensions.Sync.Registries[regID]).Msg(msg)
|
||||
|
||||
return fmt.Errorf("%w: %s", zerr.ErrBadConfig, msg)
|
||||
}
|
||||
|
||||
// check preserveDigest without compat
|
||||
if regCfg.PreserveDigest && !config.IsCompatEnabled() {
|
||||
msg := "can not use PreserveDigest option without enabling http.Compat"
|
||||
log.Error().Err(zerr.ErrBadConfig).Int("id", regID).Interface("extensions.sync.registries[id]",
|
||||
config.Extensions.Sync.Registries[regID]).Msg(msg)
|
||||
|
||||
return fmt.Errorf("%w: %s", zerr.ErrBadConfig, msg)
|
||||
}
|
||||
|
||||
@@ -1064,6 +1064,28 @@ storage:
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("Test verify with bad preserve digest and no compat", t, func(c C) {
|
||||
tmpfile, err := os.CreateTemp("", "zot-test*.json")
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
defer os.Remove(tmpfile.Name()) // clean up
|
||||
|
||||
content := []byte(`{"storage":{"rootDirectory":"/tmp/zot"},
|
||||
"http":{"address":"127.0.0.1","port":"8080","realm":"zot",
|
||||
"auth":{"htpasswd":{"path":"test/data/htpasswd"},"failDelay":1}},
|
||||
"extensions":{"sync": {"registries": [{"urls":["localhost:9999"],
|
||||
"maxRetries": 1, "retryDelay": "10s",
|
||||
"preserveDigest": true}]}}}`)
|
||||
_, err = tmpfile.Write(content)
|
||||
So(err, ShouldBeNil)
|
||||
err = tmpfile.Close()
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
os.Args = []string{"cli_test", "verify", tmpfile.Name()}
|
||||
err = cli.NewServerRootCmd().Execute()
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("Test verify with bad sync content config", t, func(c C) {
|
||||
tmpfile, err := os.CreateTemp("", "zot-test*.json")
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Reference in New Issue
Block a user