Documentation
¶
Index ¶
- func DefaultUpdateCallback(e casbin.IEnforcer) func(string)
- func NewWatcher(client dynamic.Interface, gvr schema.GroupVersionResource, namespace string, ...) (persist.Watcher, error)
- type MSG
- type UpdateType
- type Watcher
- func (w *Watcher) Close()
- func (w *Watcher) SetUpdateCallback(callback func(string)) error
- func (w *Watcher) Update() error
- func (w *Watcher) UpdateForAddPolicies(sec string, ptype string, rules ...[]string) error
- func (w *Watcher) UpdateForAddPolicy(sec string, ptype string, params ...string) error
- func (w *Watcher) UpdateForPolicy(method UpdateType, sec string, ptype string, params []string, rules [][]string, ...) error
- func (w *Watcher) UpdateForPolicyWithFieldIndex(method UpdateType, sec string, ptype string, fieldIndex int, ...) error
- func (w *Watcher) UpdateForRemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (w *Watcher) UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) error
- func (w *Watcher) UpdateForRemovePolicy(sec string, ptype string, params ...string) error
- func (w *Watcher) UpdateForSavePolicy(sec string, ptype string, params ...string) error
- func (w *Watcher) UpdateForUpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error
- func (w *Watcher) UpdateForUpdatePolicy(sec string, ptype string, oldRule, newRule []string) error
- type WatcherOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultUpdateCallback ¶
DefaultUpdateCallback returns the default callback function for policy updates.
func NewWatcher ¶
func NewWatcher(client dynamic.Interface, gvr schema.GroupVersionResource, namespace string, options WatcherOptions) (persist.Watcher, error)
NewWatcher creates a new Watcher instance.
Types ¶
type MSG ¶
type MSG struct {
Method UpdateType `json:"method"`
ID string `json:"id"`
Sec string `json:"sec,omitempty"`
Ptype string `json:"ptype,omitempty"`
OldRule []string `json:"oldRule,omitempty"`
OldRules [][]string `json:"oldRules,omitempty"`
NewRule []string `json:"newRule,omitempty"`
NewRules [][]string `json:"newRules,omitempty"`
FieldIndex int `json:"fieldIndex,omitempty"`
FieldValues []string `json:"fieldValues,omitempty"`
}
MSG represents a policy update message.
func (*MSG) MarshalBinary ¶
MarshalBinary implements binary marshaling for MSG.
func (*MSG) UnmarshalBinary ¶
UnmarshalBinary implements binary unmarshaling for MSG.
type UpdateType ¶
type UpdateType string
UpdateType represents the type of policy update.
const ( Update UpdateType = "Update" UpdateForAddPolicy UpdateType = "UpdateForAddPolicy" UpdateForRemovePolicy UpdateType = "UpdateForRemovePolicy" UpdateForRemoveFilteredPolicy UpdateType = "UpdateForRemoveFilteredPolicy" UpdateForSavePolicy UpdateType = "UpdateForSavePolicy" UpdateForAddPolicies UpdateType = "UpdateForAddPolicies" UpdateForRemovePolicies UpdateType = "UpdateForRemovePolicies" UpdateForUpdatePolicy UpdateType = "UpdateForUpdatePolicy" UpdateForUpdatePolicies UpdateType = "UpdateForUpdatePolicies" )
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher implements the persist.Watcher interface for Kubernetes CRD-based policy updates.
func (*Watcher) SetUpdateCallback ¶
SetUpdateCallback sets the callback function to be called when a policy update is detected.
func (*Watcher) UpdateForAddPolicies ¶
UpdateForAddPolicies triggers an update for AddPolicies.
func (*Watcher) UpdateForAddPolicy ¶
UpdateForAddPolicy triggers an update for AddPolicy.
func (*Watcher) UpdateForPolicy ¶
func (w *Watcher) UpdateForPolicy(method UpdateType, sec string, ptype string, params []string, rules [][]string, fieldIndex int) error
UpdateForPolicy is a helper method for triggering policy updates.
func (*Watcher) UpdateForPolicyWithFieldIndex ¶
func (w *Watcher) UpdateForPolicyWithFieldIndex(method UpdateType, sec string, ptype string, fieldIndex int, fieldValues ...string) error
UpdateForPolicyWithFieldIndex is a helper method for filtered policy updates.
func (*Watcher) UpdateForRemoveFilteredPolicy ¶
func (w *Watcher) UpdateForRemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
UpdateForRemoveFilteredPolicy triggers an update for RemoveFilteredPolicy.
func (*Watcher) UpdateForRemovePolicies ¶
UpdateForRemovePolicies triggers an update for RemovePolicies.
func (*Watcher) UpdateForRemovePolicy ¶
UpdateForRemovePolicy triggers an update for RemovePolicy.
func (*Watcher) UpdateForSavePolicy ¶
UpdateForSavePolicy triggers an update for SavePolicy.
type WatcherOptions ¶
type WatcherOptions struct {
// LocalID is a unique identifier for this watcher instance.
// If empty, a UUID will be generated.
LocalID string
// IgnoreSelf determines whether to ignore updates triggered by this watcher instance.
IgnoreSelf bool
// ResyncPeriod is the period for the informer to resync with the API server.
// Default is 30 seconds.
ResyncPeriod time.Duration
// OptionalUpdateCallback is an optional callback function that can be set during initialization.
OptionalUpdateCallback func(string)
}
WatcherOptions configures the Watcher behavior.