Skip to content

Add runtime per-bucket pub/sub notification configuration API - #2157

Merged
fsouza merged 7 commits into
fsouza:mainfrom
drehelis:main
Mar 31, 2026
Merged

Add runtime per-bucket pub/sub notification configuration API#2157
fsouza merged 7 commits into
fsouza:mainfrom
drehelis:main

Conversation

@drehelis

Copy link
Copy Markdown
Contributor

Following #2131,

I was thinking that maybe runtime configuration is a better approach to add support for multiple pub/sub notification configurations. Extending proposed solution also to per-bucket notification.

How this works:

1. Start fake-gcs server

PUBSUB_EMULATOR_HOST=host.docker.internal:8085 go run main.go -scheme http -port 4443 --filesystem-root ./storage

2. Create a bucket

curl -s -X POST http://localhost:4443/storage/v1/b \
  -H 'Content-Type: application/json' \
  -d '{"name": "my-bucket"}'
  
3. Add a notification config for OBJECT_FINALIZE events

curl -s -X POST http://localhost:4443/storage/v1/b/my-bucket/notificationConfigs \
  -H 'Content-Type: application/json' \
  -d '{
    "topic": "projects/my-project/topics/my-topic",
    "payload_format": "JSON_API_V1",
    "event_types": ["OBJECT_FINALIZE"],
    "object_name_prefix": "uploads/"
  }'

4. Trigger an event

curl -s -X POST \
  "http://localhost:4443/upload/storage/v1/b/my-bucket/o?uploadType=media&name=uploads/test.txt" \
  -H 'Content-Type: text/plain' \
  -d 'hello world'

Result:
image

Supported events are: OBJECT_FINALIZE, OBJECT_DELETE, OBJECT_METADATA_UPDATE, OBJECT_ARCHIVE

Full disclosure:
I'm the author of gcp-emulator-ui which is also a fake-gcs UI interface and a runtime configuration is better suited then the proposed init config in #2135

Comment thread internal/notification/registry.go Outdated
Comment thread fakestorage/notification_test.go
Comment thread fakestorage/object.go Outdated
@drehelis
drehelis requested a review from fsouza March 13, 2026 23:59
@drehelis

Copy link
Copy Markdown
Contributor Author

Hey @fsouza, can you have another look?

@fsouza fsouza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fsouza
fsouza merged commit 6f935ce into fsouza:main Mar 31, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants