mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
Added new extension "sync"
Periodically poll registries and pull images according to sync's config Added sync on demand, syncing when clients asks for an image which zot doesn't have. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
committed by
Ramkumar Chinchani
parent
1027f872ec
commit
19003e8a71
@@ -11,7 +11,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anuvu/zot/pkg/api"
|
||||
ext "github.com/anuvu/zot/pkg/extensions"
|
||||
"github.com/anuvu/zot/pkg/api/config"
|
||||
extconf "github.com/anuvu/zot/pkg/extensions/config"
|
||||
"github.com/anuvu/zot/pkg/extensions/search/common"
|
||||
"github.com/anuvu/zot/pkg/log"
|
||||
"github.com/anuvu/zot/pkg/storage"
|
||||
@@ -214,18 +215,18 @@ func TestLatestTagSearchHTTP(t *testing.T) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
config := api.NewConfig()
|
||||
config.HTTP.Port = Port1
|
||||
config.Storage.RootDirectory = rootDir
|
||||
config.Storage.SubPaths = make(map[string]api.StorageConfig)
|
||||
config.Storage.SubPaths["/a"] = api.StorageConfig{RootDirectory: subRootDir}
|
||||
config.Extensions = &ext.ExtensionConfig{
|
||||
Search: &ext.SearchConfig{Enable: true},
|
||||
conf := config.New()
|
||||
conf.HTTP.Port = Port1
|
||||
conf.Storage.RootDirectory = rootDir
|
||||
conf.Storage.SubPaths = make(map[string]config.StorageConfig)
|
||||
conf.Storage.SubPaths["/a"] = config.StorageConfig{RootDirectory: subRootDir}
|
||||
conf.Extensions = &extconf.ExtensionConfig{
|
||||
Search: &extconf.SearchConfig{Enable: true},
|
||||
}
|
||||
|
||||
config.Extensions.Search.CVE = nil
|
||||
conf.Extensions.Search.CVE = nil
|
||||
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
|
||||
go func() {
|
||||
// this blocks
|
||||
|
||||
@@ -13,7 +13,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anuvu/zot/pkg/api"
|
||||
ext "github.com/anuvu/zot/pkg/extensions"
|
||||
"github.com/anuvu/zot/pkg/api/config"
|
||||
extconf "github.com/anuvu/zot/pkg/extensions/config"
|
||||
"github.com/anuvu/zot/pkg/extensions/search/common"
|
||||
cveinfo "github.com/anuvu/zot/pkg/extensions/search/cve"
|
||||
"github.com/anuvu/zot/pkg/log"
|
||||
@@ -448,26 +449,26 @@ func TestCVESearch(t *testing.T) {
|
||||
updateDuration, _ = time.ParseDuration("1h")
|
||||
port := getFreePort()
|
||||
baseURL := getBaseURL(port)
|
||||
config := api.NewConfig()
|
||||
config.HTTP.Port = port
|
||||
conf := config.New()
|
||||
conf.HTTP.Port = port
|
||||
htpasswdPath := makeHtpasswdFile()
|
||||
defer os.Remove(htpasswdPath)
|
||||
|
||||
config.HTTP.Auth = &api.AuthConfig{
|
||||
HTPasswd: api.AuthHTPasswd{
|
||||
conf.HTTP.Auth = &config.AuthConfig{
|
||||
HTPasswd: config.AuthHTPasswd{
|
||||
Path: htpasswdPath,
|
||||
},
|
||||
}
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
c.Config.Storage.RootDirectory = dbDir
|
||||
cveConfig := &ext.CVEConfig{
|
||||
cveConfig := &extconf.CVEConfig{
|
||||
UpdateInterval: updateDuration,
|
||||
}
|
||||
searchConfig := &ext.SearchConfig{
|
||||
searchConfig := &extconf.SearchConfig{
|
||||
CVE: cveConfig,
|
||||
Enable: true,
|
||||
}
|
||||
c.Config.Extensions = &ext.ExtensionConfig{
|
||||
c.Config.Extensions = &extconf.ExtensionConfig{
|
||||
Search: searchConfig,
|
||||
}
|
||||
go func() {
|
||||
@@ -673,18 +674,18 @@ func TestCVESearch(t *testing.T) {
|
||||
|
||||
func TestCVEConfig(t *testing.T) {
|
||||
Convey("Verify CVE config", t, func() {
|
||||
config := api.NewConfig()
|
||||
port := config.HTTP.Port
|
||||
conf := config.New()
|
||||
port := conf.HTTP.Port
|
||||
baseURL := getBaseURL(port)
|
||||
htpasswdPath := makeHtpasswdFile()
|
||||
defer os.Remove(htpasswdPath)
|
||||
|
||||
config.HTTP.Auth = &api.AuthConfig{
|
||||
HTPasswd: api.AuthHTPasswd{
|
||||
conf.HTTP.Auth = &config.AuthConfig{
|
||||
HTPasswd: config.AuthHTPasswd{
|
||||
Path: htpasswdPath,
|
||||
},
|
||||
}
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
firstDir, err := ioutil.TempDir("", "oci-repo-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -703,8 +704,8 @@ func TestCVEConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
c.Config.Storage.RootDirectory = firstDir
|
||||
subPaths := make(map[string]api.StorageConfig)
|
||||
subPaths["/a"] = api.StorageConfig{
|
||||
subPaths := make(map[string]config.StorageConfig)
|
||||
subPaths["/a"] = config.StorageConfig{
|
||||
RootDirectory: secondDir,
|
||||
}
|
||||
c.Config.Storage.SubPaths = subPaths
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anuvu/zot/pkg/api"
|
||||
ext "github.com/anuvu/zot/pkg/extensions"
|
||||
"github.com/anuvu/zot/pkg/api/config"
|
||||
extconf "github.com/anuvu/zot/pkg/extensions/config"
|
||||
digestinfo "github.com/anuvu/zot/pkg/extensions/search/digest"
|
||||
"github.com/anuvu/zot/pkg/log"
|
||||
"github.com/anuvu/zot/pkg/storage"
|
||||
@@ -183,14 +184,14 @@ func TestDigestInfo(t *testing.T) {
|
||||
|
||||
func TestDigestSearchHTTP(t *testing.T) {
|
||||
Convey("Test image search by digest scanning", t, func() {
|
||||
config := api.NewConfig()
|
||||
config.HTTP.Port = Port1
|
||||
config.Storage.RootDirectory = rootDir
|
||||
config.Extensions = &ext.ExtensionConfig{
|
||||
Search: &ext.SearchConfig{Enable: true},
|
||||
conf := config.New()
|
||||
conf.HTTP.Port = Port1
|
||||
conf.Storage.RootDirectory = rootDir
|
||||
conf.Extensions = &extconf.ExtensionConfig{
|
||||
Search: &extconf.SearchConfig{Enable: true},
|
||||
}
|
||||
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
|
||||
go func() {
|
||||
// this blocks
|
||||
@@ -309,13 +310,13 @@ func TestDigestSearchHTTP(t *testing.T) {
|
||||
|
||||
func TestDigestSearchHTTPSubPaths(t *testing.T) {
|
||||
Convey("Test image search by digest scanning using storage subpaths", t, func() {
|
||||
config := api.NewConfig()
|
||||
config.HTTP.Port = Port1
|
||||
config.Extensions = &ext.ExtensionConfig{
|
||||
Search: &ext.SearchConfig{Enable: true},
|
||||
conf := config.New()
|
||||
conf.HTTP.Port = Port1
|
||||
conf.Extensions = &extconf.ExtensionConfig{
|
||||
Search: &extconf.SearchConfig{Enable: true},
|
||||
}
|
||||
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
|
||||
globalDir, err := ioutil.TempDir("", "digest_test")
|
||||
if err != nil {
|
||||
@@ -325,9 +326,9 @@ func TestDigestSearchHTTPSubPaths(t *testing.T) {
|
||||
|
||||
c.Config.Storage.RootDirectory = globalDir
|
||||
|
||||
subPathMap := make(map[string]api.StorageConfig)
|
||||
subPathMap := make(map[string]config.StorageConfig)
|
||||
|
||||
subPathMap["/a"] = api.StorageConfig{RootDirectory: subRootDir}
|
||||
subPathMap["/a"] = config.StorageConfig{RootDirectory: subRootDir}
|
||||
|
||||
c.Config.Storage.SubPaths = subPathMap
|
||||
|
||||
@@ -380,14 +381,14 @@ func TestDigestSearchDisabled(t *testing.T) {
|
||||
Convey("Test disabling image search", t, func() {
|
||||
dir, err := ioutil.TempDir("", "digest_test")
|
||||
So(err, ShouldBeNil)
|
||||
config := api.NewConfig()
|
||||
config.HTTP.Port = Port1
|
||||
config.Storage.RootDirectory = dir
|
||||
config.Extensions = &ext.ExtensionConfig{
|
||||
Search: &ext.SearchConfig{Enable: false},
|
||||
conf := config.New()
|
||||
conf.HTTP.Port = Port1
|
||||
conf.Storage.RootDirectory = dir
|
||||
conf.Extensions = &extconf.ExtensionConfig{
|
||||
Search: &extconf.SearchConfig{Enable: false},
|
||||
}
|
||||
|
||||
c := api.NewController(config)
|
||||
c := api.NewController(conf)
|
||||
|
||||
go func() {
|
||||
// this blocks
|
||||
|
||||
Reference in New Issue
Block a user