diff --git a/deploy/clowdapp.yaml b/deploy/clowdapp.yaml index ea82e1616..92a998d67 100644 --- a/deploy/clowdapp.yaml +++ b/deploy/clowdapp.yaml @@ -53,6 +53,8 @@ objects: value: ${NEWER_RELEASEVER_CSAF} - name: ENABLE_GO_CVES value: ${ENABLE_GO_CVES} + - name: ENABLE_GO_ERRATA + value: ${ENABLE_GO_ERRATA} resources: limits: cpu: ${CPU_LIMIT_WEBAPP_GO} @@ -499,3 +501,6 @@ parameters: - name: ENABLE_GO_CVES description: Enable go implementation of the cves endpoint value: "false" +- name: ENABLE_GO_ERRATA + description: Enable go implementation of the errata endpoint + value: "false" diff --git a/vmaas-go/base/utils/config.go b/vmaas-go/base/utils/config.go index cca8fd67a..ff4be7f19 100644 --- a/vmaas-go/base/utils/config.go +++ b/vmaas-go/base/utils/config.go @@ -46,6 +46,7 @@ type Config struct { CacheRefreshInterval time.Duration EnableProfiler bool EnableGoCves bool + EnableGoErrata bool // lib UnfixedEvalEnabled bool @@ -136,6 +137,7 @@ func initEnv() { Cfg.NewerReleaseverRepos = GetBoolEnvOrDefault("NEWER_RELEASEVER_REPOS", true) Cfg.NewerReleaseverCsaf = GetBoolEnvOrDefault("NEWER_RELEASEVER_CSAF", true) Cfg.EnableGoCves = GetBoolEnvOrDefault("ENABLE_GO_CVES", false) + Cfg.EnableGoErrata = GetBoolEnvOrDefault("ENABLE_GO_ERRATA", false) } func (e *Endpoint) BuildURL(scheme string) string { diff --git a/vmaas-go/go.mod b/vmaas-go/go.mod index 44cb5f11c..8e7edb76a 100644 --- a/vmaas-go/go.mod +++ b/vmaas-go/go.mod @@ -11,7 +11,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/redhatinsights/app-common-go v1.6.8 github.com/redhatinsights/platform-go-middlewares v1.0.0 - github.com/redhatinsights/vmaas-lib v1.14.7-0.20250110172305-47fcde3ab5ec + github.com/redhatinsights/vmaas-lib v1.14.7 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.10.0 github.com/zsais/go-gin-prometheus v0.1.0 diff --git a/vmaas-go/go.sum b/vmaas-go/go.sum index ebb30af85..bf422115d 100644 --- a/vmaas-go/go.sum +++ b/vmaas-go/go.sum @@ -117,6 +117,8 @@ github.com/redhatinsights/platform-go-middlewares v1.0.0 h1:OxyiYt+VmNo+UucK/ey0 github.com/redhatinsights/platform-go-middlewares v1.0.0/go.mod h1:dRH6XOjiZDbw8STvk6NNC7mMwqhTaV7X+1tn1oXOs24= github.com/redhatinsights/vmaas-lib v1.14.7-0.20250110172305-47fcde3ab5ec h1:zPmL4fay1/v7Vv3BP3r/qmhiMZn+2ThfKDElJ1nQdRY= github.com/redhatinsights/vmaas-lib v1.14.7-0.20250110172305-47fcde3ab5ec/go.mod h1:3jRU3URLLzBTdBfdN2Dn0eK+sCoAW4MJvD40rD2xKkk= +github.com/redhatinsights/vmaas-lib v1.14.7 h1:EwFa6M+sNjRQ/SD48wEkvMZnXiMdzvQnIoG8kYo3h9E= +github.com/redhatinsights/vmaas-lib v1.14.7/go.mod h1:3jRU3URLLzBTdBfdN2Dn0eK+sCoAW4MJvD40rD2xKkk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= diff --git a/vmaas-go/webapp/controllers/errata.go b/vmaas-go/webapp/controllers/errata.go new file mode 100644 index 000000000..252cffd80 --- /dev/null +++ b/vmaas-go/webapp/controllers/errata.go @@ -0,0 +1,44 @@ +package controllers + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/redhatinsights/vmaas-lib/vmaas" + "github.com/redhatinsights/vmaas/base/core" + "github.com/redhatinsights/vmaas/base/utils" +) + +func ErrataHandler(c *gin.Context) { + if !isCacheLoaded(c) { + return + } + erratum := c.Param("erratum") + req := vmaas.ErrataRequest{Errata: []string{erratum}} + + res, err := core.VmaasAPI.Errata(&req) + if err != nil { + utils.LogAndRespError(c, err) + return + } + c.JSON(http.StatusOK, res) +} + +func ErrataPostHandler(c *gin.Context) { + if !isCacheLoaded(c) { + return + } + req := vmaas.ErrataRequest{} + err := bindValidateJSON(c, &req) + if err != nil { + utils.LogAndRespBadRequest(c, err) + return + } + + errata, err := core.VmaasAPI.Errata(&req) + if err != nil { + utils.LogAndRespError(c, err) + return + } + c.JSON(http.StatusOK, errata) +} diff --git a/vmaas-go/webapp/routes/routes.go b/vmaas-go/webapp/routes/routes.go index f6a2461f5..c4a8473a7 100644 --- a/vmaas-go/webapp/routes/routes.go +++ b/vmaas-go/webapp/routes/routes.go @@ -18,4 +18,8 @@ func InitAPI(api *gin.RouterGroup) { api.GET("/cves/:cve", controllers.CvesHandler) api.POST("/cves", controllers.CvesPostHandler) } + if utils.Cfg.EnableGoErrata { + api.GET("/errata/:erratum", controllers.ErrataHandler) + api.POST("/errata", controllers.ErrataPostHandler) + } }