Skip to content

Commit

Permalink
Did we screw up named patterns somehow
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps committed Oct 24, 2024
1 parent 2f1854f commit eb2713a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions controllers/auth_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,21 +1001,15 @@ func buildPredicates(authConfig *api.AuthConfig, patterns []api.PatternExpressio

func buildJSONExpressionPatterns(authConfig *api.AuthConfig, pattern api.PatternExpressionOrRef) ([]jsonexp.Expression, error) {
expressionsToAdd := api.PatternExpressions{}
expressions := make([]jsonexp.Expression, len(expressionsToAdd))
if expressionsByRef, found := authConfig.Spec.NamedPatterns[pattern.PatternRef.Name]; found {
expressionsToAdd = append(expressionsToAdd, expressionsByRef...)
} else if pattern.PatternExpression.Operator != "" {
expressionsToAdd = append(expressionsToAdd, pattern.PatternExpression)
} else if pattern.Predicate != "" {
if predicate, err := cel.NewPredicate(pattern.Predicate); err != nil {
return nil, err
} else {
expressions = append(expressions, predicate)
}
}

for _, expression := range expressionsToAdd {
expressions = append(expressions, buildJSONExpressionPattern(expression))
expressions := make([]jsonexp.Expression, len(expressionsToAdd))
for i, expression := range expressionsToAdd {
expressions[i] = buildJSONExpressionPattern(expression)
}
return expressions, nil
}
Expand Down

0 comments on commit eb2713a

Please sign in to comment.