(rules []rule, prefixName string)
| 268 | } |
| 269 | |
| 270 | func 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 |
no test coverage detected