MSP-8299 add new handling for SECRET type variables and sensitive fields in config
This commit is contained in:
1 parent
780c2232fb
commit
9e7af0df5a
16 files changed
+1449
-67
No files matched your search
+32
-2
@@ -5,11 +5,12 @@ import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/middlewares/sql_metrics"
|
||||
"isp-config-service/service/rqlite/db"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type Variable struct {
|
||||
@@ -66,6 +67,35 @@ func (r Variable) GetByName(ctx context.Context, name string) (*entity.Variable,
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r Variable) GetVariablesByName(ctx context.Context, names map[string]struct{}) ([]entity.Variable, error) {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Variables.GetObjectsByName")
|
||||
|
||||
ns := make([]string, 0, len(names))
|
||||
for n := range names {
|
||||
ns = append(ns, n)
|
||||
}
|
||||
|
||||
if len(ns) == 0 {
|
||||
return []entity.Variable{}, nil
|
||||
}
|
||||
|
||||
query, args, err := squirrel.Select("name", "type").
|
||||
From(Table("variable")).
|
||||
Where(squirrel.Eq{"name": ns}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
result := make([]entity.Variable, 0)
|
||||
err = r.db.Select(ctx, &result, query, args...)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Variable) Insert(ctx context.Context, variable entity.Variable) error {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.Insert")
|
||||
|
||||
|
||||
Reference in new issue
Block a user