MCPcopy
hub / github.com/apache/casbin / GetValuesForFieldInPolicyAllTypesByName

Method GetValuesForFieldInPolicyAllTypesByName

model/policy.go:440–459  ·  view source on GitHub ↗

GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.

(sec string, field string)

Source from the content-addressed store, hash-verified

438
439// GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
440func (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}

Callers 3

GetAllSubjectsMethod · 0.80
GetAllObjectsMethod · 0.80
GetAllActionsMethod · 0.80

Calls 3

GetFieldIndexMethod · 0.95
ArrayRemoveDuplicatesFunction · 0.92

Tested by

no test coverage detected