{"id":18098720,"url":"https://github.com/krzko/proto2yaml","last_synced_at":"2025-04-13T13:08:03.893Z","repository":{"id":36976218,"uuid":"384575191","full_name":"krzko/proto2yaml","owner":"krzko","description":"🔄 A command-line utility to export Protocol Buffers (proto) files to YAML and JSON","archived":false,"fork":false,"pushed_at":"2024-04-25T04:53:13.000Z","size":1768,"stargazers_count":19,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T13:07:55.404Z","etag":null,"topics":["convert","export","grpc","json","protobuf","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krzko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-10T00:00:09.000Z","updated_at":"2024-11-02T22:56:21.000Z","dependencies_parsed_at":"2023-02-13T16:46:09.897Z","dependency_job_id":"981652aa-7b39-41a5-9cf6-341505269c77","html_url":"https://github.com/krzko/proto2yaml","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzko%2Fproto2yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzko%2Fproto2yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzko%2Fproto2yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzko%2Fproto2yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krzko","download_url":"https://codeload.github.com/krzko/proto2yaml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717242,"owners_count":21150389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert","export","grpc","json","protobuf","yaml"],"created_at":"2024-10-31T20:12:31.359Z","updated_at":"2025-04-13T13:08:03.868Z","avatar_url":"https://github.com/krzko.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proto2yaml\n\n🔄 A command-line utility to export Protocol Buffers (proto) files to YAML, and JSON.\n\nCurrently supported exports are for:\n\n* Packages\n* Services\n* RPCs\n\nSupported filters are for:\n\n* Options\n\n## Overview\n\nWe needed an intermediatate format to allow us to provision [Service Level Objective](https://cloud.google.com/service-mesh/docs/observability/slo-overview) resources using [terraform](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_slo).\n\nThe idea is to enumerate the associated protos and parse the export using a `yamldecode()` or `jsondecode()` function and prepolute our variables.\n\nAddition features such as filtering and [OpenSLO](https://github.com/OpenSLO/OpenSLO) export formating coming.\n\n## Output\n\n`proto2yaml` will export your `.proto` files using the following format;\n\n```yaml\nversion: v0.0.5\npackages:\n  - package: foo.service.profile.v1\n    services:\n      - service: ProfileAPI\n        rpc:\n          - name: GetProfiles\n            type: unary\n      - service: AdminAPI\n        rpc:\n          - name: CreateProfile\n            type: unary\n          - name: DeleteProfile\n            type: unary\n          - name: SyncProfile\n            type: server-streaming\n```\n\n## Getting started\n\nRunning `proto2yaml` is availabile through several methods. You can using `brew`, download it as a binary from GitHub releases, or running it as a distroless docker image.\n\n### brew\n\nInstall [brew](https://brew.sh/) and then run:\n\n```sh\nbrew install krzko/tap/proto2yaml\n```\n\n### Download Binary\n\nDownload the latest version from the [Releases](https://github.com/krzko/proto2yaml/releases) page.\n\n### Docker\n\nAttach a [bind mount](https://docs.docker.com/storage/bind-mounts/#start-a-container-with-a-bind-mount) to the source directory and the directory you want to export the file to.\n\nTo see all the tags view the [Packages](https://github.com/krzko/proto2yaml/pkgs/container/proto2yaml) page.\n\nTo run the docker image follow these examples:\n\n```sh\n# Use current directory as source\ndocker run --rm \\\n    -v \"$(pwd)\":/searchme \\\n    ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme\n\n# Use an explicit path as source\ndocker run --rm \\\n    -v \"/Users/foobar/code/protos\":/searchme \\\n    ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme\n\n# Use an explicit path as source and current as export\ndocker run --rm \\\n    -v \"/Users/foobar/code/protos\":/searchme \\\n    -v \"$(pwd)\":/save \\\n    ghcr.io/krzko/proto2yaml:latest yaml print --source /searchme --file /save/example_protos.yaml\n```\n\n## Run\n\n```sh\nNAME:\n   proto2yaml - A command-line utility to convert Protocol Buffers (proto) files to YAML\n\nUSAGE:\n   proto2yaml [global options] command [command options] [arguments...]\n\nVERSION:\n   proto2yaml version v0.0.6-9ad396c (2022-07-21T05:33:05Z)\n\nCOMMANDS:\n   json     The outputs are formatted as JSON\n   yaml     The outputs are formatted as YAML\n   help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --help, -h     show help (default: false)\n   --version, -v  print the version (default: false)\n```\n\n### Export\n\nTo export to a file, run the following command\n\n```sh\n# JSON\nproto2yaml json export --source ./protos --file ./example_protos.json\n# JSON pretty\nproto2yaml json export --source ./protos --file ./example_protos.json --pretty\n\n# YAML\nproto2yaml yaml export --source ./protos --file ./example_protos.yaml\n```\n\n### Filter\n\nTo filter on an `option` you can use the `--exclude-option` or `--include-option` filter. For now its based on singletons but hope to expand out multiple combinations in the future. An example is as follows:\n\n```sh\nproto2yaml yaml print --source ./protos --exclude-option \"deprecated=true\"\n```\n\nOr run the inverse of the above using:\n\n```sh\nproto2yaml yaml print --source ./protos --include-option \"deprecated=true\"\n```\n\n### Print\n\nTo print to the console, clone the repo and run the following command:\n\n```sh\n# JSON\nproto2yaml json print --source ./protos\n# JSON pretty\nproto2yaml json print --source ./protos --pretty\n\n# YAML\nproto2yaml yaml print --source ./protos\n```\n\n### Disable Colour\n\nIf 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:\n\n```sh\nexport NO_COLOR=\"true\"\n```\n\nTo enable colour again, simply `unset` the variable:\n\n```sh\nunset NO_COLOR\n```\n\n## Build \u0026 Run\n\nTo build to the binaries use the following targets. All outputs are generated to the `bin` directory.\n\n### All\n\nTo build all the the targets, simply run:\n\n```sh\n# Default target invoked\nmake\n\n# Explicit target\nmake build\n```\n\nTo run all the builds without Docker, simply run:\n\n```sh\nmake build-no-docker\n```\n\n### Linux\n\nThe following targets will generate your Linux binaries:\n\n```sh\nmake build-linux\n```\n\n### macOS\n\nmacOS 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:\n\n```sh\n# For intel macs\nmake build-darwin-amd64\n# For m1 macs\nmake build-darwin-arm64\n```\n\n### Windows\n\nThe following targets will generate your Windows executable:\n\n```sh\nmake build-windows\n```\n\n### Others\n\nThe general `make build` and `back-build-no-docker` targets will also build **Raspberry Pi** and **FreeBSD** version, along with a **distroless Docker** image, if selected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzko%2Fproto2yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrzko%2Fproto2yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzko%2Fproto2yaml/lists"}