diff --git a/examples/README.md b/examples/README.md index f9dc841c..3fa1b018 100644 --- a/examples/README.md +++ b/examples/README.md @@ -388,8 +388,8 @@ Configure each registry sync: "pollInterval": "6h", # polling interval, if not set then periodically polling will not run "tlsVerify": true, # whether or not to verify tls (default is true) "certDir": "/home/user/certs", # use certificates at certDir path, if not specified then use the default certs dir - "maxRetries": 5, # mandatory option! maxRetries in case of temporary errors - "retryDelay": "10m", # mandatory option! delay between retries, retry options are applied for both on demand and periodically sync. + "maxRetries": 5, # maxRetries in case of temporary errors (default: no retries) + "retryDelay": "10m", # delay between retries, retry options are applied for both on demand and periodically sync and retryDelay is mandatory when using maxRetries. "content":[ # which content to periodically pull, also it's used for filtering ondemand images, if not set then periodically polling will not run { "prefix":"/repo1/repo", # pull image repo1/repo @@ -411,8 +411,6 @@ Configure each registry sync: "pollInterval": "12h", "tlsVerify": false, "onDemand": false, - "maxRetries": 5, - "retryDelay": "10m", "content":[ { "prefix":"/repo2", @@ -426,11 +424,11 @@ Configure each registry sync: "urls": ["https://docker.io/library"], "onDemand": true, # doesn't have content, don't periodically pull, pull just on demand. "tlsVerify": true, - "maxRetries": 3, + "maxRetries": 3, "retryDelay": "15m" } ] } ``` -Prefixes can be strings that exactly match repositories or they can be glob patterns. +Prefixes can be strings that exactly match repositories or they can be [glob](https://en.wikipedia.org/wiki/Glob_(programming)) patterns. diff --git a/examples/config-sync.json b/examples/config-sync.json index 9cd847ce..62aaa3cd 100644 --- a/examples/config-sync.json +++ b/examples/config-sync.json @@ -40,8 +40,6 @@ "pollInterval": "12h", "tlsVerify": false, "onDemand": false, - "maxRetries": 5, - "retryDelay": "10m", "content":[ { "prefix":"/repo2", diff --git a/pkg/cli/root.go b/pkg/cli/root.go index 725dad5c..4bb72b31 100644 --- a/pkg/cli/root.go +++ b/pkg/cli/root.go @@ -246,11 +246,11 @@ func validateConfiguration(config *config.Config) { // check glob patterns in sync config are compilable if config.Extensions != nil && config.Extensions.Sync != nil { - for _, regCfg := range config.Extensions.Sync.Registries { + for id, regCfg := range config.Extensions.Sync.Registries { // check retry options are configured for sync - if regCfg.MaxRetries == nil || regCfg.RetryDelay == nil { - log.Error().Err(errors.ErrBadConfig).Msg("extensions.sync.registries[].MaxRetries" + - "and extensions.sync.registries[].RetryDelay fields are mandatory") + if regCfg.MaxRetries != nil && regCfg.RetryDelay == nil { + log.Error().Err(errors.ErrBadConfig).Msgf("extensions.sync.registries[%d].retryDelay"+ + " is required when using extensions.sync.registries[%d].maxRetries", id, id) panic(errors.ErrBadConfig) } diff --git a/pkg/cli/root_test.go b/pkg/cli/root_test.go index a8f93e85..084b99d5 100644 --- a/pkg/cli/root_test.go +++ b/pkg/cli/root_test.go @@ -267,7 +267,7 @@ func TestVerify(t *testing.T) { "http":{"address":"127.0.0.1","port":"8080","realm":"zot", "auth":{"htpasswd":{"path":"test/data/htpasswd"},"failDelay":1}}, "extensions":{"sync": {"registries": [{"urls":["localhost:9999"], - "content": [{"prefix":"repo**"}]}]}}}`) + "maxRetries": 10, "content": [{"prefix":"repo**"}]}]}}}`) _, err = tmpfile.Write(content) So(err, ShouldBeNil) err = tmpfile.Close()