0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

build: increase wait timeout for travis bazel build process

This commit is contained in:
Shivam Mishra 2020-10-22 17:31:16 -07:00
parent 46beb30fc1
commit b0ed625a2e
8 changed files with 68 additions and 18 deletions

View file

@ -22,7 +22,7 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -N https://github.com/bazelbuild/bazel/releases/download/3.0.0/bazel-3.0.0-installer-linux-x86_64.sh && chmod +x bazel-3.0.0-installer-linux-x86_64.sh && ./bazel-3.0.0-installer-linux-x86_64.sh --user; go get -u github.com/swaggo/swag/cmd/swag; go mod download; sudo apt-get update; sudo apt-get install rpm; sudo apt install snapd; sudo snap install skopeo --edge --devmode; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -N https://github.com/bazelbuild/bazel/releases/download/3.0.0/bazel-3.0.0-installer-linux-x86_64.sh && chmod +x bazel-3.0.0-installer-linux-x86_64.sh && ./bazel-3.0.0-installer-linux-x86_64.sh --user; go get -u github.com/swaggo/swag/cmd/swag; go mod download; sudo apt-get update; sudo apt-get install rpm; sudo apt install snapd; sudo snap install skopeo --edge --devmode; fi
script: script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_wait make && travis_wait make -f Makefile.bazel build; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_wait 40 make && travis_wait 40 make -f Makefile.bazel build; fi
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)

View file

@ -2,3 +2,5 @@ ignore:
- "*_gen.go" - "*_gen.go"
- "./pkg/extensions/search/*_gen.go" - "./pkg/extensions/search/*_gen.go"
- "./pkg/extensions/search/generated.go" - "./pkg/extensions/search/generated.go"
- "./pkg/extensions/minimal.go"
- "./pkg/cli/minimal.go"

View file

@ -50,9 +50,9 @@ func (c *Controller) Run() error {
os.Exit(1) os.Exit(1)
} }
// Updating the CVE Database // Enable extensions if extension config is provided
if c.Config != nil { if c.Config != nil && c.Config.Extensions != nil {
ext.EnableExtension(c.Config.Extensions, c.Log, c.Config.Storage.RootDirectory) ext.EnableExtensions(c.Config.Extensions, c.Log, c.Config.Storage.RootDirectory)
} }
c.Router = engine c.Router = engine

View file

@ -88,7 +88,7 @@ func (rh *RouteHandler) SetupRoutes() {
} }
// swagger docs "/swagger/v2/index.html" // swagger docs "/swagger/v2/index.html"
rh.c.Router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler) rh.c.Router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler)
// Zot Search Extension Router // Setup Extensions Routes
if rh.c.Config != nil && rh.c.Config.Extensions != nil { if rh.c.Config != nil && rh.c.Config.Extensions != nil {
ext.SetupRoutes(rh.c.Router, rh.c.Config.Storage.RootDirectory, rh.c.ImageStore, rh.c.Log) ext.SetupRoutes(rh.c.Router, rh.c.Config.Storage.RootDirectory, rh.c.ImageStore, rh.c.Log)
} }

View file

@ -4,7 +4,7 @@ go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"config.go", "config.go",
"extension.go", "extensions.go",
"minimal.go", "minimal.go",
], ],
importpath = "github.com/anuvu/zot/pkg/extensions", importpath = "github.com/anuvu/zot/pkg/extensions",

View file

@ -16,24 +16,24 @@ import (
) )
// DownloadTrivyDB ... // DownloadTrivyDB ...
func DownloadTrivyDB(dbDir string, log log.Logger, updateInterval time.Duration) error { func downloadTrivyDB(dbDir string, log log.Logger, updateInterval time.Duration) error {
for { for {
log.Info().Msg("Updating the CVE database") log.Info().Msg("updating the CVE database")
err := cveinfo.UpdateCVEDb(dbDir, log) err := cveinfo.UpdateCVEDb(dbDir, log)
if err != nil { if err != nil {
return err return err
} }
log.Info().Str("Db update completed, next update scheduled after", updateInterval.String()).Msg("") log.Info().Str("DB update completed, next update scheduled after", updateInterval.String()).Msg("")
time.Sleep(updateInterval) time.Sleep(updateInterval)
} }
} }
func EnableExtension(extension *ExtensionConfig, log log.Logger, rootDir string) { // EnableExtensions ...
if extension != nil && extension.Search != nil && func EnableExtensions(extension *ExtensionConfig, log log.Logger, rootDir string) {
extension.Search.CVE != nil { if extension.Search != nil && extension.Search.CVE != nil {
defaultUpdateInterval, _ := time.ParseDuration("2h") defaultUpdateInterval, _ := time.ParseDuration("2h")
if extension.Search.CVE.UpdateInterval < defaultUpdateInterval { if extension.Search.CVE.UpdateInterval < defaultUpdateInterval {
@ -43,18 +43,20 @@ func EnableExtension(extension *ExtensionConfig, log log.Logger, rootDir string)
} }
go func() { go func() {
err := DownloadTrivyDB(rootDir, log, err := downloadTrivyDB(rootDir, log,
extension.Search.CVE.UpdateInterval) extension.Search.CVE.UpdateInterval)
if err != nil { if err != nil {
panic(err) panic(err)
} }
}() }()
} else { } else {
log.Info().Msg("Cve config not provided, skipping cve update") log.Info().Msg("CVE config not provided, skipping CVE update")
} }
} }
// SetupRoutes ...
func SetupRoutes(router *mux.Router, rootDir string, imgStore *storage.ImageStore, log log.Logger) { func SetupRoutes(router *mux.Router, rootDir string, imgStore *storage.ImageStore, log log.Logger) {
log.Info().Msg("setting up extensions routes")
resConfig := search.GetResolverConfig(rootDir, log, imgStore) resConfig := search.GetResolverConfig(rootDir, log, imgStore)
router.PathPrefix("/query").Methods("GET", "POST"). router.PathPrefix("/query").Methods("GET", "POST").
Handler(gqlHandler.NewDefaultServer(search.NewExecutableSchema(resConfig))) Handler(gqlHandler.NewDefaultServer(search.NewExecutableSchema(resConfig)))

View file

@ -11,13 +11,16 @@ import (
) )
// DownloadTrivyDB ... // DownloadTrivyDB ...
func DownloadTrivyDB(dbDir string, log log.Logger, updateInterval time.Duration) error { func downloadTrivyDB(dbDir string, log log.Logger, updateInterval time.Duration) error {
return nil return nil
} }
func EnableExtension(extension *ExtensionConfig, log log.Logger, rootDir string) { // EnableExtensions ...
log.Info().Msg("given zot binary doesn't support any extensions, please build zot full binary for this feature") func EnableExtensions(extension *ExtensionConfig, log log.Logger, rootDir string) {
log.Warn().Msg("skipping enabling extensions because given zot binary doesn't support any extensions, please build zot full binary for this feature")
} }
// SetupRoutes ...
func SetupRoutes(router *mux.Router, rootDir string, imgStore *storage.ImageStore, log log.Logger) { func SetupRoutes(router *mux.Router, rootDir string, imgStore *storage.ImageStore, log log.Logger) {
log.Warn().Msg("skipping setting up extensions routes because given zot binary doesn't support any extensions, please build zot full binary for this feature")
} }

View file

@ -684,3 +684,46 @@ func TestCVESearch(t *testing.T) {
So(resp.StatusCode(), ShouldEqual, 200) So(resp.StatusCode(), ShouldEqual, 200)
}) })
} }
func TestCVEConfig(t *testing.T) {
Convey("Verify CVE config", t, func() {
config := api.NewConfig()
config.HTTP.Port = SecurePort1
htpasswdPath := makeHtpasswdFile()
defer os.Remove(htpasswdPath)
config.HTTP.Auth = &api.AuthConfig{
HTPasswd: api.AuthHTPasswd{
Path: htpasswdPath,
},
}
c := api.NewController(config)
dir, err := ioutil.TempDir("", "oci-repo-test")
if err != nil {
panic(err)
}
defer os.RemoveAll(dir)
c.Config.Storage.RootDirectory = dir
c.Config.Extensions = &ext.ExtensionConfig{}
go func() {
// this blocks
if err := c.Run(); err != nil {
return
}
}()
// wait till ready
for {
_, err := resty.R().Get(BaseURL1)
if err == nil {
break
}
time.Sleep(100 * time.Millisecond)
}
defer func() {
ctx := context.Background()
_ = c.Server.Shutdown(ctx)
}()
})
}