openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
286 stars 107 forks source link

Support Upcoming Protobuf Changes #379

Open robshakir opened 4 years ago

robshakir commented 4 years ago

Enhance the protobuf generation by adding:

wenovus commented 4 years ago

Subsumes #208

mmellin commented 2 years ago

Currently we are experiencing many build errors related to go_package from running these generated proto files through the grpc_gateway tool. Example errors:

> --openapiv2_out: unable to determine Go import path for "example.com/devicemanager/openconfig/enums/enums.proto"
 > 
 > Please specify either:
 >      • a "go_package" option in the .proto source file, or
 >      • a "M" argument on the command line.

Do you have any ideas for workarounds prior to this functionality being enabled?

robshakir commented 2 years ago

We actually already implemented this -- see https://github.com/openconfig/ygot/blob/a776802e8a810a2f41a9cd3a8bb567c800e16a51/docs/protobuf_getting_started.md

You can use the -go_package_name flag to proto_generator and it will add the relevant annotation.

HTH! r.

mmellin commented 2 years ago

Thanks @robshakir. I was reading through the latest releases source and I don't see that flag defined in protogenerator.go. In fact when I try it out, I get this error:

 flag provided but not defined: -go_package_name 

I'm using the v0.12.6 latest release. I'm sorry, but I must be missing something simple. Where is the flag -go_package_name?

wenovus commented 2 years ago

Hi Matt, the flag's name is -go_package_base, the relative package path of the proto will be appended to it to form the go_package name. See the first snippet in this heading: https://github.com/openconfig/ygot/blob/a776802e8a810a2f41a9cd3a8bb567c800e16a51/docs/protobuf_getting_started.md#generating-openconfig-bgp-rib-protobufs

mmellin commented 2 years ago

Ah ok, understood. Thank you. Perhaps consider then updating the docs? I think there is a docs bug with a typo saying -go_package_name= when you really mean -go_package_base=.