mirror of
https://github.com/project-zot/zot.git
synced 2025-01-06 22:40:28 -05:00
c0aaca8ed1
(cherry picked from commit d557da0baba819b7cd7e6b5941528776e125ac6d) build(ui): fix stacker builds (cherry picked from commit ba25daf02b4a9bc7ee1cb6f84b7a6b096ca7d61f) build(ui): various fixes - Fix metrics endpoint - Fix unit tests unit tests - Make the ui build optional in the makefile before the linter lint runs in the golangci-lint workflow - Do not attempt to include UI routes if search is enabled - Fix authorization for search endpoint fix: use zot tag in ui make target (cherry picked from commit 2a6882fa23f06b2d68c6c299773a6ff50bf90e78) Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> Signed-off-by: Catalin Hofnar <catalin.hofnar@gmail.com> Signed-off-by: Andrei Aaron <aaaron@luxoft.com> Co-authored-by: Ramkumar Chinchani <rchincha@cisco.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
//go:build debug
|
|
// +build debug
|
|
|
|
package debug
|
|
|
|
import (
|
|
"embed"
|
|
"html/template"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
"zotregistry.io/zot/pkg/api/constants"
|
|
debugCst "zotregistry.io/zot/pkg/debug/constants"
|
|
"zotregistry.io/zot/pkg/log"
|
|
"zotregistry.io/zot/pkg/storage"
|
|
)
|
|
|
|
//go:embed index.html.tmpl
|
|
var playgroundHTML embed.FS
|
|
|
|
// SetupGQLPlaygroundRoutes ...
|
|
func SetupGQLPlaygroundRoutes(conf *config.Config, router *mux.Router,
|
|
storeController storage.StoreController, l log.Logger,
|
|
) {
|
|
log := log.Logger{Logger: l.With().Caller().Timestamp().Logger()}
|
|
log.Info().Msg("setting up graphql playground route")
|
|
|
|
templ, err := template.ParseFS(playgroundHTML, "index.html.tmpl")
|
|
if err != nil {
|
|
log.Fatal().Err(err)
|
|
}
|
|
|
|
//nolint:lll
|
|
router.PathPrefix(debugCst.GQLPlaygroundEndpoint).HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
|
writer.Header().Add("Content-Type", "text/html")
|
|
|
|
proto := ""
|
|
|
|
if req.TLS == nil {
|
|
proto += "http://"
|
|
} else {
|
|
proto += "https://"
|
|
}
|
|
|
|
target := proto + req.Host + constants.FullSearchPrefix
|
|
|
|
// respond with the output of template execution
|
|
_ = templ.Execute(writer, struct {
|
|
Target string
|
|
}{Target: target})
|
|
})
|
|
}
|