Repository: project-zot/zot

Issue:
[Bug]: can't disable sync extension
### zot version

main

### Describe the bug

`enable: false` has no effect if any registry configuration is set in the config object.

```go
// IsSyncEnabled checks if sync is enabled in this extensions config.
func (e *ExtensionConfig) IsSyncEnabled() bool {
	if e == nil {
		return false
	}

	// Sync is enabled if either:
	// 1. Explicitly enabled (Enable == true), OR
	// 2. There are registries configured (enabled by default when registries exist)
	// This matches the behavior in root.go where Sync.Enable defaults to true when registries are present
	return e.Sync != nil && ((e.Sync.Enable != nil && *e.Sync.Enable) || len(e.Sync.Registries) > 0)
}
```

If `e.Sync.Enable` is false, the condition falls back on the last `len(e.Sync.Registries) > 0`. If this is true, then the function returns true instead of false.

### To reproduce

1. Configuration

A configuration with at least on registry configured in the sync extension and the extension disabled using `enable: false`.

2. Client tool used

`crane manifest xyz`

3. Seen error

The logs show the sync extension being triggered

### Expected behavior

The extension should be disabled.

### Screenshots

_No response_

### Additional context

_No response_

Hints from issue comments:

Solution patch:
diff --git a/pkg/extensions/config/config.go b/pkg/extensions/config/config.go
index d05e11bd..3764355f 100644
--- a/pkg/extensions/config/config.go
+++ b/pkg/extensions/config/config.go
@@ -126,7 +126,8 @@ func (e *ExtensionConfig) IsSyncEnabled() bool {
 	// 1. Explicitly enabled (Enable == true), OR
 	// 2. There are registries configured (enabled by default when registries exist)
 	// This matches the behavior in root.go where Sync.Enable defaults to true when registries are present
-	return e.Sync != nil && ((e.Sync.Enable != nil && *e.Sync.Enable) || len(e.Sync.Registries) > 0)
+	return e.Sync != nil && ((e.Sync.Enable != nil && *e.Sync.Enable) ||
+		(e.Sync.Enable == nil && len(e.Sync.Registries) > 0))
 }
 
 // IsScrubEnabled checks if scrub is enabled in this extensions config.



Test patch:
diff --git a/pkg/extensions/config/config_test.go b/pkg/extensions/config/config_test.go
index c174b8b7..93dbd402 100644
--- a/pkg/extensions/config/config_test.go
+++ b/pkg/extensions/config/config_test.go
@@ -57,6 +57,11 @@ func buildSyncConfig(enabled bool) *config.ExtensionConfig {
 	ext := &config.ExtensionConfig{}
 	ext.Sync = &sync.Config{
 		Enable: &enabled,
+		Registries: []sync.RegistryConfig{
+			{
+				URLs: []string{"localhost"},
+			},
+		},
 	}
 
 	return ext