removeFilteredPolicy removes rules based on field filters from the current policy.
(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string)
| 764 | |
| 765 | // removeFilteredPolicy removes rules based on field filters from the current policy. |
| 766 | func (e *ContextEnforcer) removeFilteredPolicyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) { |
| 767 | ok, err := e.removeFilteredPolicyWithoutNotifyCtx(ctx, sec, ptype, fieldIndex, fieldValues) |
| 768 | if !ok || err != nil { |
| 769 | return ok, err |
| 770 | } |
| 771 | |
| 772 | if e.shouldNotify() { |
| 773 | var err error |
| 774 | if watcher, ok := e.watcher.(persist.WatcherEx); ok { |
| 775 | err = watcher.UpdateForRemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...) |
| 776 | } else { |
| 777 | err = e.watcher.Update() |
| 778 | } |
| 779 | return true, err |
| 780 | } |
| 781 | |
| 782 | return true, nil |
| 783 | } |
| 784 | |
| 785 | func (e *ContextEnforcer) updateFilteredPoliciesCtx(ctx context.Context, sec string, ptype string, newRules [][]string, fieldIndex int, fieldValues ...string) (bool, error) { |
| 786 | oldRules, err := e.updateFilteredPoliciesWithoutNotifyCtx(ctx, sec, ptype, newRules, fieldIndex, fieldValues...) |
no test coverage detected