Skip to content

Commit

Permalink
Merge pull request #1060 from cristiansteib/custom-event-configuration
Browse files Browse the repository at this point in the history
Configure properties of posted K8s events
  • Loading branch information
nolar authored Oct 8, 2023
2 parents 04bbbb5 + ff27f90 commit b35ab78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kopf/_cogs/clients/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ async def post_event(
body = {
'metadata': {
'namespace': namespace,
'generateName': 'kopf-event-',
'generateName': settings.posting.event_name_prefix,
},

'action': 'Action?',
'type': type,
'reason': reason,
'message': message,

'reportingComponent': 'kopf',
'reportingInstance': 'dev',
'source' : {'component': 'kopf'}, # used in the "From" column in `kubectl describe`.
'reportingComponent': settings.posting.reporting_component,
'reportingInstance': settings.posting.reporting_instance,
'source': {'component': settings.posting.reporting_component}, # used in the "From" column in `kubectl describe`.

'involvedObject': full_ref,

Expand Down
4 changes: 4 additions & 0 deletions kopf/_cogs/configs/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class PostingSettings:
(``kopf.info()``, ``kopf.warn()``, ``kopf.exception()``).
"""

reporting_component: str = 'kopf'
reporting_instance: str = 'dev'
event_name_prefix: str = 'kopf-event-'


@dataclasses.dataclass
class PeeringSettings:
Expand Down

0 comments on commit b35ab78

Please sign in to comment.