mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
core/lint: upgrade golangci-lint, replace interface{} with any (#5099)
* core/lint: upgrade golangci-lint, replace interface{} with any * regen proto
This commit is contained in:
parent
614048ae9c
commit
1a5b8b606f
135 changed files with 341 additions and 340 deletions
|
@ -34,7 +34,7 @@ var (
|
|||
types.Args(types.S, types.S),
|
||||
types.NewObject(nil, types.NewDynamicProperty(types.S, types.S)),
|
||||
),
|
||||
}, func(bctx rego.BuiltinContext, op1 *ast.Term, op2 *ast.Term) (*ast.Term, error) {
|
||||
}, func(_ rego.BuiltinContext, op1 *ast.Term, op2 *ast.Term) (*ast.Term, error) {
|
||||
serviceAccount, ok := op1.Value.(ast.String)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid service account type: %T", op1)
|
||||
|
@ -65,7 +65,7 @@ type gcpIdentityTokenSource struct {
|
|||
}
|
||||
|
||||
func (src *gcpIdentityTokenSource) Token() (*oauth2.Token, error) {
|
||||
res, err, _ := src.singleflight.Do("", func() (interface{}, error) {
|
||||
res, err, _ := src.singleflight.Do("", func() (any, error) {
|
||||
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, GCPIdentityDocURL+"?"+url.Values{
|
||||
"format": {"full"},
|
||||
"audience": {src.audience},
|
||||
|
|
|
@ -62,7 +62,7 @@ var variableSubstitutionFunctionRegoOption = rego.Function2(®o.Function{
|
|||
),
|
||||
types.Named("output", types.S),
|
||||
),
|
||||
}, func(bctx rego.BuiltinContext, op1 *ast.Term, op2 *ast.Term) (*ast.Term, error) {
|
||||
}, func(_ rego.BuiltinContext, op1 *ast.Term, op2 *ast.Term) (*ast.Term, error) {
|
||||
inputString, ok := op1.Value.(ast.String)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid input_string type: %T", op1.Value)
|
||||
|
@ -143,18 +143,18 @@ func (e *HeadersEvaluator) Evaluate(ctx context.Context, req *HeadersRequest) (*
|
|||
func (e *HeadersEvaluator) getHeader(vars rego.Vars) http.Header {
|
||||
h := make(http.Header)
|
||||
|
||||
m, ok := vars["result"].(map[string]interface{})
|
||||
m, ok := vars["result"].(map[string]any)
|
||||
if !ok {
|
||||
return h
|
||||
}
|
||||
|
||||
m, ok = m["identity_headers"].(map[string]interface{})
|
||||
m, ok = m["identity_headers"].(map[string]any)
|
||||
if !ok {
|
||||
return h
|
||||
}
|
||||
|
||||
for k := range m {
|
||||
vs, ok := m[k].([]interface{})
|
||||
vs, ok := m[k].([]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ func TestNewHeadersRequestFromPolicy_nil(t *testing.T) {
|
|||
func TestHeadersEvaluator(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type A = []interface{}
|
||||
type M = map[string]interface{}
|
||||
type A = []any
|
||||
type M = map[string]any
|
||||
|
||||
signingKey, err := cryptutil.NewSigningKey()
|
||||
require.NoError(t, err)
|
||||
|
@ -114,7 +114,7 @@ func TestHeadersEvaluator(t *testing.T) {
|
|||
// between numeric formats.
|
||||
d := json.NewDecoder(bytes.NewReader(decodeJWSPayload(t, jwtHeader)))
|
||||
d.UseNumber()
|
||||
var jwtPayloadDecoded map[string]interface{}
|
||||
var jwtPayloadDecoded map[string]any
|
||||
err = d.Decode(&jwtPayloadDecoded)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func NewPolicyResponse() *PolicyResponse {
|
|||
type RuleResult struct {
|
||||
Value bool
|
||||
Reasons criteria.Reasons
|
||||
AdditionalData map[string]interface{}
|
||||
AdditionalData map[string]any
|
||||
}
|
||||
|
||||
// NewRuleResult creates a new RuleResult.
|
||||
|
@ -51,7 +51,7 @@ func NewRuleResult(value bool, reasons ...criteria.Reason) RuleResult {
|
|||
return RuleResult{
|
||||
Value: value,
|
||||
Reasons: criteria.NewReasons(reasons...),
|
||||
AdditionalData: map[string]interface{}{},
|
||||
AdditionalData: map[string]any{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ func (e *PolicyEvaluator) evaluateQuery(ctx context.Context, req *PolicyRequest,
|
|||
func (e *PolicyEvaluator) getRuleResult(name string, vars rego.Vars) (result RuleResult) {
|
||||
result = NewRuleResult(false)
|
||||
|
||||
m, ok := vars["result"].(map[string]interface{})
|
||||
m, ok := vars["result"].(map[string]any)
|
||||
if !ok {
|
||||
return result
|
||||
}
|
||||
|
@ -244,10 +244,10 @@ func (e *PolicyEvaluator) getRuleResult(name string, vars rego.Vars) (result Rul
|
|||
switch t := m[name].(type) {
|
||||
case bool:
|
||||
result.Value = t
|
||||
case []interface{}:
|
||||
case []any:
|
||||
switch len(t) {
|
||||
case 3:
|
||||
v, ok := t[2].(map[string]interface{})
|
||||
v, ok := t[2].(map[string]any)
|
||||
if ok {
|
||||
for k, vv := range v {
|
||||
result.AdditionalData[k] = vv
|
||||
|
@ -256,7 +256,7 @@ func (e *PolicyEvaluator) getRuleResult(name string, vars rego.Vars) (result Rul
|
|||
fallthrough
|
||||
case 2:
|
||||
// fill in the reasons
|
||||
v, ok := t[1].([]interface{})
|
||||
v, ok := t[1].([]any)
|
||||
if ok {
|
||||
for _, vv := range v {
|
||||
result.Reasons.Add(criteria.Reason(fmt.Sprint(vv)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue