removePolicy removes a rule from the current policy.
(sec string, ptype string, rule []string)
| 421 | |
| 422 | // removePolicy removes a rule from the current policy. |
| 423 | func (e *Enforcer) removePolicy(sec string, ptype string, rule []string) (bool, error) { |
| 424 | ok, err := e.logPolicyOperation(log.EventRemovePolicy, sec, rule, func() (bool, error) { |
| 425 | return e.removePolicyWithoutNotify(sec, ptype, rule) |
| 426 | }) |
| 427 | |
| 428 | if !ok || err != nil { |
| 429 | return ok, err |
| 430 | } |
| 431 | |
| 432 | if e.shouldNotify() { |
| 433 | var notifyErr error |
| 434 | if watcher, isWatcherEx := e.watcher.(persist.WatcherEx); isWatcherEx { |
| 435 | notifyErr = watcher.UpdateForRemovePolicy(sec, ptype, rule...) |
| 436 | } else { |
| 437 | notifyErr = e.watcher.Update() |
| 438 | } |
| 439 | return true, notifyErr |
| 440 | } |
| 441 | |
| 442 | return true, nil |
| 443 | } |
| 444 | |
| 445 | func (e *Enforcer) updatePolicy(sec string, ptype string, oldRule []string, newRule []string) (bool, error) { |
| 446 | ok, err := e.updatePolicyWithoutNotify(sec, ptype, oldRule, newRule) |
no test coverage detected