Skip to content

Commit

Permalink
api.main: publish events on build channel
Browse files Browse the repository at this point in the history
Open a new PubSub channel to publish kernel build nodes
i.e. `build`. The events on this channel would not have
`owner` information associated. Hence, subscribers will
receive all the build events and not just filtered events
by node owners.

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
  • Loading branch information
Jeny Sadadia committed May 7, 2024
1 parent 7878729 commit 116ac65
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ async def post_node(node: Node,
obj = await db.create(node)
data = _get_node_event_data('created', obj)
attributes = {}
# publish 'build' event without setting owner
await pubsub.publish_cloudevent('build', data, attributes)
if data.get('owner', None):
attributes['owner'] = data['owner']
await pubsub.publish_cloudevent('node', data, attributes)
Expand Down Expand Up @@ -635,6 +637,8 @@ async def put_node(node_id: str, node: Node,
obj = await db.update(new_node_def)
data = _get_node_event_data('updated', obj)
attributes = {}
# publish 'build' event without setting owner
await pubsub.publish_cloudevent('build', data, attributes)
if data.get('owner', None):
attributes['owner'] = data['owner']
await pubsub.publish_cloudevent('node', data, attributes)
Expand Down

0 comments on commit 116ac65

Please sign in to comment.