🔄 A command-line utility to export Protocol Buffers (proto) files to YAML, and JSON

proto2yaml

🔄 A command-line utility to export Protocol Buffers (proto) files to YAML, and JSON.

Currently supported exports are for:

  • Packages
  • Services
  • RPCs

Supported filters are for:

  • Options

Overview

We needed an intermediatate format to allow us to provision Service Level Objective resources using terraform.

The idea is to enumerate the associated protos and parse the export using a yamldecode() or jsondecode() function and prepolute our variables.

Addition features such as filtering and OpenSLO export formating coming.

Getting started

Running 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 Binary

Download the latest release.

Docker

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

Export

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

Filter

To 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:

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"

Print

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

Disable Colour

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:

export NO_COLOR="true"

To enable colour again, simply unset the variable:

unset NO_COLOR

Build & Run

To build to the binaries use the following targets. All outputs are generated to the bin directory.

All

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:

make build-no-docker

Linux

The following targets will generate your Linux binaries:

make build-linux

macOS

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

Windows

The following targets will generate your Windows executable:

make build-windows

Others

The 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.

Owner
Comments
Watcher - A simple command line app to watch files in a directory for changes and run a command when files change!

Watcher - Develop your programs easily Watcher watches all the files present in the directory it is run from of the directory that is specified while

Mar 27, 2022
Hosty is a command-line utility that allows for fast inspection and editing of /etc/hosts-like files

Hosty Description Hosty is a command-line utility that allows for fast inspection and editing of /etc/hosts-like files. It is written in golang and us

Sep 3, 2021
Json-match - Command line util for matching values in a JSON input

json-match Match JSON input by specifying key and value > json-match -json '{\"p

Jan 12, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct-tool Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command und

Dec 16, 2021
yq is a portable command-line YAML processor

yq a lightweight and portable command-line YAML processor. yq uses jq like syntax but works with yaml files as well as json. It doesn't yet support ev

Dec 29, 2022
Xopopu - Export csv to json for web preview

xopopu Diagram English Document La idea es crear una herramienta de backend que

Feb 2, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
A command line utility and library for generating professional looking invoices in Go.
A command line utility and library for generating professional looking invoices in Go.

ginvoicer A command line utility and library for generating professional looking invoices in Go. This is a very rough draft and there could still be b

Dec 15, 2022
Portal is a quick and easy command-line file transfer utility from any computer to another 🖥️ 🌌 💻
Portal is a quick and easy command-line file transfer utility from any computer to another 🖥️ 🌌 💻

Portal is a quick and easy command-line file transfer utility from any computer to another ??️ ?? ??

Dec 27, 2022
A command line utility for labeling GitHub issues and pull requests

A command line utility for labeling GitHub issues and pull requests

Jan 8, 2023
Gopassutil - Command line utility to hash and verify with passlib for go

gopassutil command line utility to hash and verify with passlib for go Usage Gen

Feb 1, 2022
Utility CLI to convert Spring Boot Yaml configuration into external configuration

boot-config-export Utility CLI to convert Spring Boot Yaml configuration into external configuration (as environment variables). The variables are tra

Nov 17, 2021
Related is a simple cli utility tool to create files or a group of files.

Related - Create files based on individual definitions or groups Related helps with common file-creation-based tasks. You can predefine single types a

Apr 16, 2022
đź“· Command-line utility to download all photos from Instagram
đź“· Command-line utility to download all photos from Instagram

Instagram Downloader This is a simple command-line tool, written in Go, to download all images from an Instagram account. Getting Started Install inst

Sep 9, 2022
A command line utility for generating language-specific project structure.
A command line utility for generating language-specific project structure.

hydra hydra is a command line utility for generating language-specific project structures. ⏬ ✨ Features Build project templates with just one command

Oct 8, 2021
A small utility command line application that can recursively download Notion pages

notionbackup A small utility command line application that can recursively download Notion pages. I needed something scriptable that could periodicall

Dec 5, 2022
Aces is a command line utility that lets you encode any file to a character set of your choice.

Aces Any Character Encoding Set Aces is a command line utility that lets you encode any file to a character set of your choice. For example, you could

Nov 28, 2022