Added graphql api feature for image vulnerability scanning

This commit is contained in:
Shivam Mishra
2020-06-26 12:09:10 -07:00
parent baa5d247ec
commit 2cf2c16137
14 changed files with 3455 additions and 3 deletions
+2
View File
@@ -16,9 +16,11 @@ go_library(
deps = [
"//docs:go_default_library",
"//errors:go_default_library",
"//pkg/extensions/search:go_default_library",
"//pkg/extensions/search/cve:go_default_library",
"//pkg/log:go_default_library",
"//pkg/storage:go_default_library",
"@com_github_99designs_gqlgen//graphql/handler:go_default_library",
"@com_github_chartmuseum_auth//:go_default_library",
"@com_github_getlantern_deepcopy//:go_default_library",
"@com_github_go_ldap_ldap_v3//:go_default_library",
+11
View File
@@ -21,8 +21,10 @@ import (
"strconv"
"strings"
gqlHandler "github.com/99designs/gqlgen/graphql/handler"
_ "github.com/anuvu/zot/docs" // as required by swaggo
"github.com/anuvu/zot/errors"
"github.com/anuvu/zot/pkg/extensions/search"
"github.com/anuvu/zot/pkg/log"
"github.com/gorilla/mux"
jsoniter "github.com/json-iterator/go"
@@ -50,6 +52,11 @@ func NewRouteHandler(c *Controller) *RouteHandler {
return rh
}
func (rh *RouteHandler) searchHandler() *gqlHandler.Server {
resConfig := search.GetResolverConfig(rh.c.Config.Storage.RootDirectory, rh.c.Log, rh.c.ImageStore)
return gqlHandler.NewDefaultServer(search.NewExecutableSchema(resConfig))
}
// blobRLockWrapper calls the real handler with read-lock held.
func (rh *RouteHandler) blobRLockWrapper(f func(w http.ResponseWriter,
r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
@@ -107,6 +114,10 @@ func (rh *RouteHandler) SetupRoutes() {
}
// swagger docs "/swagger/v2/index.html"
rh.c.Router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler)
// Zot Search Extension Router
if rh.c.Config != nil && rh.c.Config.Extensions != nil {
rh.c.Router.PathPrefix("/query").Methods("GET", "POST").Handler(rh.searchHandler())
}
}
// Method handlers