Removed swagger requirement from binary-minimal and binary (#838)

Signed-off-by: Catalin Hofnar <catalin.hofnar@gmail.com>
This commit is contained in:
Catalin Hofnar
2022-10-03 19:53:44 +03:00
committed by GitHub
parent f658ef66ee
commit bd9e6fc7e3
5 changed files with 59 additions and 17 deletions
+24
View File
@@ -0,0 +1,24 @@
//go:build debug
// +build debug
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
package debug
import (
"github.com/gorilla/mux"
httpSwagger "github.com/swaggo/http-swagger"
"zotregistry.io/zot/pkg/api/config"
"zotregistry.io/zot/pkg/log" // nolint:goimports
// as required by swaggo.
_ "zotregistry.io/zot/swagger"
)
func SetupSwaggerRoutes(conf *config.Config, router *mux.Router, log log.Logger,
) {
log.Info().Msg("setting up swagger route")
// swagger swagger "/swagger/v2/index.html"
router.PathPrefix("/swagger/v2/").Methods("GET").Handler(httpSwagger.WrapHandler)
}
+23
View File
@@ -0,0 +1,23 @@
//go:build !debug
// +build !debug
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
package debug
import (
"github.com/gorilla/mux"
"zotregistry.io/zot/pkg/api/config"
"zotregistry.io/zot/pkg/log" // nolint:goimports
// as required by swaggo.
_ "zotregistry.io/zot/swagger"
)
func SetupSwaggerRoutes(conf *config.Config, router *mux.Router, log log.Logger,
) {
// swagger swagger "/swagger/v2/index.html"
log.Warn().Msg("skipping enabling swagger because given zot binary" +
"doesn't include this feature, please build a binary that does so")
}