Skip to content

Commit b35ab78

Browse files
authored
Merge pull request #1060 from cristiansteib/custom-event-configuration
Configure properties of posted K8s events
2 parents 04bbbb5 + ff27f90 commit b35ab78

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

kopf/_cogs/clients/events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ async def post_event(
5353
body = {
5454
'metadata': {
5555
'namespace': namespace,
56-
'generateName': 'kopf-event-',
56+
'generateName': settings.posting.event_name_prefix,
5757
},
5858

5959
'action': 'Action?',
6060
'type': type,
6161
'reason': reason,
6262
'message': message,
6363

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

6868
'involvedObject': full_ref,
6969

kopf/_cogs/configs/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class PostingSettings:
8080
(``kopf.info()``, ``kopf.warn()``, ``kopf.exception()``).
8181
"""
8282

83+
reporting_component: str = 'kopf'
84+
reporting_instance: str = 'dev'
85+
event_name_prefix: str = 'kopf-event-'
86+
8387

8488
@dataclasses.dataclass
8589
class PeeringSettings:

0 commit comments

Comments
 (0)