Currently supported exports are for:
Supported filters are for:
The idea is to enumerate the associated protos and parse the export using a
jsondecode() function and prepolute our variables.
Addition features such as filtering and OpenSLO export formating coming.
proto2yaml is availabile through several methods. You can download it as a binary from GitHub releases, running it as a distroless docker image or building it from source.
NAME: proto2yaml - A command-line utility to convert Protocol Buffers (proto) files to YAML USAGE: proto2yaml [global options] command [command options] [arguments...] VERSION: 0.0.3 COMMANDS: json The outputs are formatted as JSON yaml The outputs are formatted as YAML help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --help, -h show help (default: false) --version, -v print the version (default: false)
Download the latest release.
Attach a bind mount to the source directory and the directory you want to export the file to.
# Use current directory as source docker run --rm \ -v "$(pwd)":/searchme \ ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme # Use an explicit path as source docker run --rm \ -v "/Users/foobar/code/protos":/searchme \ ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme # Use an explicit path as source and current as export docker run --rm \ -v "/Users/foobar/code/protos":/searchme \ -v "$(pwd)":/save \ ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme --file /save/example_protos.yaml
To export to a file, run the following command
# JSON proto2yaml json export --source ./protos --file ./example_protos.json # JSON pretty proto2yaml json export --source ./protos --file ./example_protos.json --pretty # YAML proto2yaml yaml export --source ./protos --file ./example_protos.yaml
To filter on an
option you can use the
--include-option filter. For now its based on singletons but hope to expand out multiple combinations in the future. An example is as follows:
proto2yaml yaml print --source ./protos --exclude-option "deprecated=true"
Or run the inverse of the above using:
proto2yaml yaml print --source ./protos --include-option "deprecated=true"
To print to the console, clone the repo and run the following command:
# JSON proto2yaml json print --source ./protos # JSON pretty proto2yaml json print --source ./protos --pretty # YAML proto2yaml yaml print --source ./protos
If you need to run the tool in your CI/CD pipelines and ANSI isn't supported, you can pass the following variable to disable colour:
To enable colour again, simply
unset the variable:
Build & Run
To build to the binaries use the following targets. All outputs are generated to the
To build all the the targets, simply run:
# Default target invoked make # Explicit target make build
To run all the builds without Docker, simply run:
The following targets will generate your Linux binaries:
macOS has two targets, one for the older Intel
amd64 CPUs and one for the newer Mx
arm64 CPUs. The following targets will generate your binaries:
# For intel macs make build-darwin-amd64 # For m1 macs make build-darwin-arm64
The following targets will generate your Windows executable:
make build and
back-build-no-docker targets will also build Raspberry Pi and FreeBSD version, along with a distroless Docker image, if selected.