MCPcopy
hub / github.com/grpc/grpc-go / parseRules

Function parseRules

authz/rbac_translator.go:270–287  ·  view source on GitHub ↗
(rules []rule, prefixName string)

Source from the content-addressed store, hash-verified

268}
269
270func parseRules(rules []rule, prefixName string) (map[string]*v3rbacpb.Policy, error) {
271 policies := make(map[string]*v3rbacpb.Policy)
272 for i, rule := range rules {
273 if rule.Name == "" {
274 return policies, fmt.Errorf(`%d: "name" is not present`, i)
275 }
276 permission, err := parseRequest(rule.Request)
277 if err != nil {
278 return nil, fmt.Errorf("%d: %v", i, err)
279 }
280 policyName := prefixName + "_" + rule.Name
281 policies[policyName] = &v3rbacpb.Policy{
282 Principals: []*v3rbacpb.Principal{parsePeer(rule.Source)},
283 Permissions: []*v3rbacpb.Permission{permission},
284 }
285 }
286 return policies, nil
287}
288
289// Parse auditLoggingOptions to the associated RBAC protos. The single
290// auditLoggingOptions results in two different parsed protos, one for the allow

Callers 1

translatePolicyFunction · 0.85

Calls 3

parseRequestFunction · 0.85
parsePeerFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected