mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
f618b1d4ef
* ci(deps): upgrade golangci-lint
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
* build(deps): removed disabled linters
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
* build(deps): go run github.com/daixiang0/gci@latest write .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run golang.org/x/tools/cmd/goimports@latest -l -w .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/bombsimon/wsl/v4/cmd...@latest -strict-append -test=true -fix ./...
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/catenacyber/perfsprint@latest -fix ./...
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): replace gomnd by mnd
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): make gqlgen
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build: Revert "build(deps): go run github.com/daixiang0/gci@latest write ."
This reverts commit 5bf8c42e1f
.
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): go run github.com/daixiang0/gci@latest write -s 'standard' -s default -s 'prefix(zotregistry.dev/zot)' .
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* build(deps): make gqlgen
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: wsl issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: check-log issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: gci issues
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
* fix: tests
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
---------
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
132 lines
3.1 KiB
Go
132 lines
3.1 KiB
Go
package config_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
"zotregistry.dev/zot/pkg/api/config"
|
|
)
|
|
|
|
func TestConfig(t *testing.T) {
|
|
Convey("Test config utils", t, func() {
|
|
firstStorageConfig := config.StorageConfig{
|
|
GC: true, Dedupe: true,
|
|
GCDelay: 1 * time.Minute, GCInterval: 1 * time.Hour,
|
|
}
|
|
secondStorageConfig := config.StorageConfig{
|
|
GC: true, Dedupe: true,
|
|
GCDelay: 1 * time.Minute, GCInterval: 1 * time.Hour,
|
|
}
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeTrue)
|
|
|
|
firstStorageConfig.GC = false
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GC = true
|
|
firstStorageConfig.Dedupe = false
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.Dedupe = true
|
|
firstStorageConfig.GCDelay = 2 * time.Minute
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GCDelay = 1 * time.Minute
|
|
firstStorageConfig.GCInterval = 2 * time.Hour
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GCInterval = 1 * time.Hour
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeTrue)
|
|
|
|
isSame, err := config.SameFile("test-config", "test")
|
|
So(err, ShouldNotBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
dir1 := t.TempDir()
|
|
|
|
isSame, err = config.SameFile(dir1, "test")
|
|
So(err, ShouldNotBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
dir2 := t.TempDir()
|
|
|
|
isSame, err = config.SameFile(dir1, dir2)
|
|
So(err, ShouldBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
isSame, err = config.SameFile(dir1, dir1)
|
|
So(err, ShouldBeNil)
|
|
So(isSame, ShouldBeTrue)
|
|
})
|
|
|
|
Convey("Test DeepCopy() & Sanitize()", t, func() {
|
|
conf := config.New()
|
|
So(conf, ShouldNotBeNil)
|
|
|
|
authConfig := &config.AuthConfig{LDAP: (&config.LDAPConfig{}).SetBindPassword("oina")}
|
|
conf.HTTP.Auth = authConfig
|
|
|
|
So(func() { conf.Sanitize() }, ShouldNotPanic)
|
|
|
|
conf = conf.Sanitize()
|
|
So(conf.HTTP.Auth.LDAP.BindPassword(), ShouldEqual, "******")
|
|
|
|
// negative
|
|
obj := make(chan int)
|
|
err := config.DeepCopy(conf, obj)
|
|
So(err, ShouldNotBeNil)
|
|
err = config.DeepCopy(obj, conf)
|
|
So(err, ShouldNotBeNil)
|
|
})
|
|
|
|
Convey("Test IsRetentionEnabled()", t, func() {
|
|
conf := config.New()
|
|
So(conf.IsRetentionEnabled(), ShouldBeFalse)
|
|
|
|
conf.Storage.Retention.Policies = []config.RetentionPolicy{
|
|
{
|
|
Repositories: []string{"repo"},
|
|
},
|
|
}
|
|
|
|
So(conf.IsRetentionEnabled(), ShouldBeFalse)
|
|
|
|
policies := []config.RetentionPolicy{
|
|
{
|
|
Repositories: []string{"repo"},
|
|
KeepTags: []config.KeepTagsPolicy{
|
|
{
|
|
Patterns: []string{"tag"},
|
|
MostRecentlyPulledCount: 2,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
conf.Storage.Retention = config.ImageRetention{
|
|
Policies: policies,
|
|
}
|
|
|
|
So(conf.IsRetentionEnabled(), ShouldBeTrue)
|
|
|
|
subPaths := make(map[string]config.StorageConfig)
|
|
|
|
subPaths["/a"] = config.StorageConfig{
|
|
GC: true,
|
|
Retention: config.ImageRetention{
|
|
Policies: policies,
|
|
},
|
|
}
|
|
|
|
conf.Storage.SubPaths = subPaths
|
|
|
|
So(conf.IsRetentionEnabled(), ShouldBeTrue)
|
|
})
|
|
}
|