Docker image to generate Go source code from Protocol Buffer schemes
September 9, 2021 ยท View on GitHub
This repository provides the Docker image used to generate the Go source code from Protocol Buffer schemes.
Build
Build of the Docker image requires docker
engine and make utility as pre-requisites. As the requirements are satisfied, use the
following command to compile the latest version of the Docker image:
make latest
Usage
To generate the Go source code using the provided tool, you could start with the following command, where
projectvariable defines the Go projectpluginvariable defines protoc plugin (go, grpc-gateway, protoc-gen-openapiv2, validate, etc.)plugin_optvariable defines options to be passed to the specified plugin{schema}variable defines your Protocol Buffer schema
NOTE It is supposed that your proto schema has proper option go_package set.
E.g: option go_package = "github.com/{your_repo}/{your_app}"
docker run --rm -v $(pwd):/go/src/${project} \
infoblox/atlas-gentool:latest --{plugin}_out={plugin_opt} ${project}/{schema}.proto
Plugins
- protoc-gen-go
- protoc-gen-go-grpc
- protoc-gen-openapiv2 (Infoblox Open with atlas-patch)
- protoc-gen-grpc-gateway (Infoblox Open)
- protoc-gen-doc
- protoc-gen-validate
- protoc-gen-govalidators
- protoc-gen-gorm (Infoblox Open)
- protoc-gen-atlas-query-validate (Infoblox Open)
- protoc-gen-atlas-validate (Infoblox Open)
- protoc-gen-preprocess (Infoblox Open)
- protoc-gen-jsonschema
protoc-gen-openapiv2 patch
atlas-patch is build on top of original protoc-gen-openapiv2 and is intended to conform atlas-app-toolkit REST API Sepcification. A full list of modifications can be found here.
Note that infobloxopen/grpc-gateway has restrictions in using it as a self-standing go module. It inherits go module path from the original grpc-ecosystem/grpc-gateway repository. Use either git tools or NOT module-aware (GOPATH based) go mode to fetch it as a dependency.