GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
(sec string, field string)
| 438 | |
| 439 | // GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed. |
| 440 | func (model Model) GetValuesForFieldInPolicyAllTypesByName(sec string, field string) ([]string, error) { |
| 441 | values := []string{} |
| 442 | |
| 443 | for ptype := range model[sec] { |
| 444 | // GetFieldIndex will return (-1, err) if field is not found, ignore it |
| 445 | index, err := model.GetFieldIndex(ptype, field) |
| 446 | if err != nil { |
| 447 | continue |
| 448 | } |
| 449 | v, err := model.GetValuesForFieldInPolicy(sec, ptype, index) |
| 450 | if err != nil { |
| 451 | return nil, err |
| 452 | } |
| 453 | values = append(values, v...) |
| 454 | } |
| 455 | |
| 456 | util.ArrayRemoveDuplicates(&values) |
| 457 | |
| 458 | return values, nil |
| 459 | } |
no test coverage detected