-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hello!
Thank you for the great work!
I'm working on a project that only a few of the protos are used for the pubsub. I'd like to generate pubsub scheme only for those protos but it generates it also for all its imported types.
What I did is to create a separate generation template buf.pubsub.gen.yaml not to generate pubsub inlines for all the protos yet I couldn't exclude the sub types.
buf.yaml
version: v2
managed:
enabled: true
disable:
- file_option: go_package
module: buf.build/googleapis/googleapis
- file_option: go_package
module: buf.build/protocolbuffers/wellknowntypes
override:
- file_option: go_package_prefix
value: example.com/theproject/packages/go/proto
plugins:
- remote: buf.build/protocolbuffers/go:v1.36.4
out: packages/go/proto
opt: paths=source_relative
- remote: buf.build/grpc/go:v1.5.1
out: packages/go/proto
opt: paths=source_relativebuf.pubsub.gen.yaml
version: v2
managed:
enabled: true
plugins:
- remote: buf.build/bufbuild/protoschema-pubsub
out: gen/proto/infra/pubsub
include_imports: false
include_wkt: false
inputs:
- directory: proto
types:
- "com.example.eventsystem.event.v1.Event"Proto directory structure:
proto
└── org
└── example
└── eventsystem
└── event
└── v1
├── event.proto
├── event_data.proto
└── service.proto
event.proto
syntax = "proto3";
package com.example.eventsystem.event.v1;
import "com.example.eventsystem/event/v1/event_data.proto";
import "google/protobuf/timestamp.proto";
// Represents a generic event that can carry various types of event data.
message Event {
// A unique identifier for this event.
string id = 1;
// The name of the event.
string name = 2;
// The user identifier associated with this event.
string user_id = 3;
// The source of the event (e.g., "web", "mobile", "system").
string source = 4;
// The timestamp indicating when the event was created.
google.protobuf.Timestamp created_at = 5;
// A oneof field containing different types of event data.
oneof event_data {
com.example.eventsystem.event.v1.EventDataEmpty emptyEvent = 9;
com.example.eventsystem.event.v1.EventDataEvent1 event1 = 10;
com.example.eventsystem.event.v1.EventDataEvent2 event2 = 11;
com.example.eventsystem.event.v1.EventDataEvent3 event3 = 12;
com.example.eventsystem.event.v1.EventDataEvent4 event4 = 13;
com.example.eventsystem.event.v1.EventDataEvent5 event5 = 14;
com.example.eventsystem.event.v1.EventDataEvent6 event6 = 15;
}
}event_data.proto
syntax = "proto3";
package com.example.eventsystem.event.v1;
message EventDataEmpty {}
message EventDataEvent1 {
string field1 = 1;
}
message EventDataEvent2 {
int32 field2 = 1;
}
message EventDataEvent3 {
bool field3 = 1;
}
message EventDataEvent4 {
...
}
message EventDataEvent5 {
...
}
message EventDataEvent6 {
...
}Generated proto:
gen
└── proto
└── infra
└── pubsub
├── com.example.eventsystem.event.v1.Event.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEmpty.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEvent1.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEvent2.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEvent3.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEvent4.pubsub.proto
├── com.example.eventsystem.event.v1.EventDataEvent5.pubsub.proto
└── com.example.eventsystem.event.v1.EventDataEvent6.pubsub.proto
From these I only need com.example.eventsystem.event.v1.Event.pubsub.proto, Is it possible to only generate this one?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels