GetValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed.
(sec string, ptype string, fieldIndex int)
| 403 | |
| 404 | // GetValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed. |
| 405 | func (model Model) GetValuesForFieldInPolicy(sec string, ptype string, fieldIndex int) ([]string, error) { |
| 406 | values := []string{} |
| 407 | |
| 408 | _, err := model.GetAssertion(sec, ptype) |
| 409 | if err != nil { |
| 410 | return nil, err |
| 411 | } |
| 412 | |
| 413 | for _, rule := range model[sec][ptype].Policy { |
| 414 | values = append(values, rule[fieldIndex]) |
| 415 | } |
| 416 | |
| 417 | util.ArrayRemoveDuplicates(&values) |
| 418 | |
| 419 | return values, nil |
| 420 | } |
| 421 | |
| 422 | // GetValuesForFieldInPolicyAllTypes gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed. |
| 423 | func (model Model) GetValuesForFieldInPolicyAllTypes(sec string, fieldIndex int) ([]string, error) { |
no test coverage detected