Events#
Class for formatting Kubernetes event messages.
- class kubespawner.events.EventFormatter(*args: t.Any, **kwargs: t.Any)#
- class kubespawner.events.BasicEventFormatter(*args: t.Any, **kwargs: t.Any)#
- class kubespawner.events.RuleEventFormatter(*args: t.Any, **kwargs: t.Any)#
- extra_rules c.RuleEventFormatter.extra_rules = Union()#
List or dictionary of additional event formatter rules on top of
RuleEventFormatter.rules. These rules are merged withRuleEventFormatter.rules. Whereextra_rulesis a dict, the name of each rule can be chosen to override a base rule.See also
RuleEventFormatter.rulesfor information on fields available in template strings.
- rules c.RuleEventFormatter.rules = Union()#
List or dictionary of event formatter rules.
A “rule” is an object that consists of two required fields:
match— an object containing regular expression patterns (strings or compiled regular expressions) that match similarly namedEventfields. Any named capture groups will be made available to thetemplate. Supported fields arereportingComponent,fieldPath,reason,message, andtype.template— a string, or a callable that will be used to build a formatted event message. If a string, the.formatmethod will be invoked with any named capture group results as keyword arguments. If a callable, the same named capture groups will be directly passed as keyword arguments. Missing named capture groups are provided as empty strings.
If provided as a list, each item should be an aforementioned “rule” object. If provided as a dictionary, the keys can be any descriptive name and the values should be the aforementioned “rule” objects. The items will be sorted lexicographically by the dictionary keys, and the sorted values will be used to build the list of rules. .. admonition:: Example
- collapsible:
closed
Here is an example of two rules that are defined by default in the
RuleEventFormatter.c.RuleEventFormatter.rules = [ { "match": { "reportingComponent": r"kubelet", "fieldPath": r"spec\.(initContainers|containers)\{(?P<container>[^}]+)\}", "reason": r"(?P<action>Pulling|Pulled)", "message": r'.*image\s*"(?P<image>[^"]+)\:(?P<tag>[^"]+)"', }, "template": "{action} image {image}:{tag} for the {container} container", }, { "match": { "reportingComponent": r"kubelet", "fieldPath": r"spec\.(initContainers|containers)\{(?P<container>[^}]+)\}", "reason": r"(?P<action>Started|Killing|Created|Stopped)", }, "template": '{action} the container "{container}"', } ]
When set to None, a default ruleset is used.
- kubespawner.events.decorate_plain_message(message: str, event: dict) str#
Build a plain-text message from a plain-text message body and an Event object.
- kubespawner.events.decorate_html_message(message: str, event: dict) str#
Build a full HTML message from a plain-text message body and an Event object.