[PR #2157] Add runtime per-bucket pub/sub notification configuration API #2147

Open
opened 2026-03-03 13:29:59 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/2157
Author: @drehelis
Created: 2/27/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (3)

  • 8fe2275 add runtime per-bucket pub/sub notification configuration API
  • 5492c62 chore: lint fix
  • b7055ab chore(fix) goroutine leak, close all clients on stop and some nitpicks

📊 Changes

8 files changed (+588 additions, -22 deletions)

View changed files

📝 fakestorage/bucket.go (+1 -0)
fakestorage/notification.go (+65 -0)
fakestorage/notification_test.go (+145 -0)
📝 fakestorage/object.go (+9 -0)
📝 fakestorage/server.go (+22 -15)
📝 internal/notification/event.go (+13 -7)
internal/notification/registry.go (+203 -0)
internal/notification/registry_test.go (+130 -0)

📄 Description

Following https://github.com/fsouza/fake-gcs-server/issues/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 https://github.com/fsouza/fake-gcs-server/pull/2135


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fsouza/fake-gcs-server/pull/2157 **Author:** [@drehelis](https://github.com/drehelis) **Created:** 2/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (3) - [`8fe2275`](https://github.com/fsouza/fake-gcs-server/commit/8fe2275fd4c65d1bdc3564a9959c436c1e381952) add runtime per-bucket pub/sub notification configuration API - [`5492c62`](https://github.com/fsouza/fake-gcs-server/commit/5492c62babf8a97dbfb829768b40ee940df554a1) chore: lint fix - [`b7055ab`](https://github.com/fsouza/fake-gcs-server/commit/b7055abd0fe02261106910c4e5d8d75de66fdfaf) chore(fix) goroutine leak, close all clients on stop and some nitpicks ### 📊 Changes **8 files changed** (+588 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `fakestorage/bucket.go` (+1 -0) ➕ `fakestorage/notification.go` (+65 -0) ➕ `fakestorage/notification_test.go` (+145 -0) 📝 `fakestorage/object.go` (+9 -0) 📝 `fakestorage/server.go` (+22 -15) 📝 `internal/notification/event.go` (+13 -7) ➕ `internal/notification/registry.go` (+203 -0) ➕ `internal/notification/registry_test.go` (+130 -0) </details> ### 📄 Description Following https://github.com/fsouza/fake-gcs-server/issues/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: <img width="1177" height="673" alt="image" src="https://github.com/user-attachments/assets/8e669311-97a2-40ef-b8e2-782ad696b7fa" /> Supported events are: `OBJECT_FINALIZE`, `OBJECT_DELETE`, `OBJECT_METADATA_UPDATE`, `OBJECT_ARCHIVE` Full disclosure: I'm the author of [gcp-emulator-ui](https://github.com/drehelis/gcp-emulator-ui) which is also a `fake-gcs` UI interface and a runtime configuration is better suited then the proposed init config in https://github.com/fsouza/fake-gcs-server/pull/2135 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#2147
No description provided.