GenerateConditionalGFunction is the factory method of the g(_, _[, _]) function with conditions.
(crm rbac.ConditionalRoleManager)
| 446 | |
| 447 | // GenerateConditionalGFunction is the factory method of the g(_, _[, _]) function with conditions. |
| 448 | func GenerateConditionalGFunction(crm rbac.ConditionalRoleManager) govaluate.ExpressionFunction { |
| 449 | return func(args ...interface{}) (interface{}, error) { |
| 450 | // Like all our other govaluate functions, all args are strings. |
| 451 | var hasLink bool |
| 452 | |
| 453 | name1, name2 := args[0].(string), args[1].(string) |
| 454 | if crm == nil { |
| 455 | hasLink = name1 == name2 |
| 456 | } else if len(args) == 2 { |
| 457 | hasLink, _ = crm.HasLink(name1, name2) |
| 458 | } else { |
| 459 | domain := args[2].(string) |
| 460 | hasLink, _ = crm.HasLink(name1, name2, domain) |
| 461 | } |
| 462 | |
| 463 | return hasLink, nil |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | // builtin LinkConditionFunc |
| 468 |
no test coverage detected
searching dependent graphs…