Skip to content

Commit

Permalink
feat: show package_name and evra in updates response
Browse files Browse the repository at this point in the history
and bump vmaas-lib
VMAAS-1458
  • Loading branch information
psegedy authored and jdobes committed Jul 10, 2023
1 parent e701693 commit 2f9ebcc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
6 changes: 5 additions & 1 deletion vmaas-go/base/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func ConfigureApp() {

func ConfigureCache() {
var err error
VmaasAPI, err = vmaas.InitFromURL(utils.Cfg.DumpAddress, &utils.Cfg.LibConfig)
VmaasAPI, err = vmaas.InitFromURL(
utils.Cfg.DumpAddress,
vmaas.WithMaxGoroutines(utils.Cfg.VmaasLibMaxGoroutines),
vmaas.WithUnfixed(utils.Cfg.OvalUnfixedEvalEnabled),
)
if err != nil {
utils.LogWarn("err", err.Error(), "Cache not available on app start")
}
Expand Down
11 changes: 5 additions & 6 deletions vmaas-go/base/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

clowder "github.com/redhatinsights/app-common-go/pkg/api/v1"
"github.com/redhatinsights/vmaas-lib/vmaas"
)

var Cfg = Config{}
Expand Down Expand Up @@ -46,8 +45,10 @@ type Config struct {
LogStyle string
CacheRefreshInterval time.Duration
EnableProfiler bool

// lib
LibConfig vmaas.Config
OvalUnfixedEvalEnabled bool
VmaasLibMaxGoroutines int
}

type (
Expand Down Expand Up @@ -127,10 +128,8 @@ func initEnv() {
cacheRefreshSec := GetIntEnvOrDefault("CACHE_REFRESH_INTERVAL", 60) // 1 min default
Cfg.CacheRefreshInterval = time.Second * time.Duration(cacheRefreshSec)
Cfg.EnableProfiler = GetBoolEnvOrDefault("ENABLE_PROFILER", false)
Cfg.LibConfig = vmaas.Config{
OvalUnfixedEvalEnabled: GetBoolEnvOrDefault("OVAL_UNFIXED_EVAL_ENABLED", true),
MaxGoroutines: GetIntEnvOrDefault("VMAAS_LIB_MAX_GOROUTINES", 20),
}
Cfg.OvalUnfixedEvalEnabled = GetBoolEnvOrDefault("OVAL_UNFIXED_EVAL_ENABLED", true)
Cfg.VmaasLibMaxGoroutines = GetIntEnvOrDefault("VMAAS_LIB_MAX_GOROUTINES", 20)
}

func (e *Endpoint) BuildURL(scheme string) string {
Expand Down
7 changes: 3 additions & 4 deletions vmaas-go/base/utils/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"net/http"
"strconv"
"strings"
"time"

"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/redhatinsights/vmaas-lib/vmaas"
)

// ReadHeaderTimeout same as nginx default
Expand Down Expand Up @@ -106,13 +106,12 @@ func respStatusError(c *gin.Context, code int, err error) {
}

func LogAndRespError(c *gin.Context, err error) {
errStr := err.Error()
if strings.Contains(errStr, "processing") {
if errors.Is(err, vmaas.ErrProcessingInput) {
// if error is from processing the request, we should return 400
LogAndRespBadRequest(c, err)
return
}
LogError("err", errStr)
LogError("err", err.Error())
respStatusError(c, http.StatusInternalServerError, err)
}

Expand Down
2 changes: 1 addition & 1 deletion vmaas-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/prometheus/client_golang v1.15.1
github.com/redhatinsights/app-common-go v1.6.6
github.com/redhatinsights/platform-go-middlewares v0.20.0
github.com/redhatinsights/vmaas-lib v0.9.0
github.com/redhatinsights/vmaas-lib v1.0.2
github.com/sirupsen/logrus v1.9.2
github.com/stretchr/testify v1.8.3
github.com/zsais/go-gin-prometheus v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions vmaas-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ github.com/redhatinsights/app-common-go v1.6.6 h1:daOwCpGtW6IxGd9iO6TY3yoaV/HaHK
github.com/redhatinsights/app-common-go v1.6.6/go.mod h1:6gzRyg8ZyejwMCksukeAhh2ZXOB3uHSmBsbP06fG2PQ=
github.com/redhatinsights/platform-go-middlewares v0.20.0 h1:qwK9ArGYRlORsZ56PXXLJrGvzTsMe3bk2lR+WN5aIjM=
github.com/redhatinsights/platform-go-middlewares v0.20.0/go.mod h1:i5gVDZJ/quCQhs5AW5CwkRPXlz1HfDBvyNtXHnlXZfM=
github.com/redhatinsights/vmaas-lib v0.9.0 h1:iU6lOaWILNfzssxnI5bQ31WRC03Qomi/nMcTzxZGpJo=
github.com/redhatinsights/vmaas-lib v0.9.0/go.mod h1:Hae6UhDkh9fdPtOOX0uhrol3B+wDSLSLeGFGpTBYCPA=
github.com/redhatinsights/vmaas-lib v1.0.2 h1:O0DHW97hk/qje1Pe35QnSN8y+tbEHw3l29GfoKEVs/Q=
github.com/redhatinsights/vmaas-lib v1.0.2/go.mod h1:Hae6UhDkh9fdPtOOX0uhrol3B+wDSLSLeGFGpTBYCPA=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
Expand Down
6 changes: 6 additions & 0 deletions vmaas/webapp/webapp.v3.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ components:
package:
type: string
example: kernel-2.6.32-696.23.1.el6.x86_64
package_name:
type: string
example: kernel
evra:
type: string
example: 0:2.6.32-696.23.1.el6.x86_64
repository_list:
type: array
items:
Expand Down

0 comments on commit 2f9ebcc

Please sign in to comment.