proto

package
v0.1.158 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: MIT Imports: 20 Imported by: 1

README

proto companion

The codefly proto companion bundles buf, protoc, protoc-gen-*, swagger, grpcio-tools, and the JS/TS generators into one OCI image. Used by codefly generate proto and the codefly generate openAPI pipeline.

Build

There are two source-of-truth options today:

Nix (preferred — reproducible, layered cache)
# From core/companions/proto/, with a Linux build target.
# On macOS, requires nix-darwin's linux-builder configured.
nix build .#dockerImage
nix run .#streamDockerImage | docker load

The Nix flake pins every transitive dependency by content hash via flake.lock. The dev shell (nix develop) uses the same package set the image ships — no drift between "works on my dev machine" and "the agent's image." Image tag is read from info.codefly.yaml so the existing tag.sh version-bump flow continues to work.

Dockerfile (legacy — kept for parity until the Nix path is

default)

./scripts/build_companion.sh

The Dockerfile assembles the same set via apk + go install. Less reproducible than Nix (apk packages vary across Alpine releases) but needs no Linux builder VM. Will be retired once Phase 1's flake-based build is the canonical path.

What's in the image

Tool Purpose
buf Modern proto compilation + linting
protoc + libprotoc Classic proto compiler (some plugins still need it)
protoc-gen-go / -go-grpc Go bindings + gRPC
protoc-gen-grpc-gateway REST-from-gRPC
protoc-gen-openapiv2 OpenAPI from gRPC
protoc-gen-connect-go Connect-RPC bindings
swagger (go-swagger) OpenAPI client generation
go + gofmt Required at runtime by swagger for source formatting
grpcio-tools (python) grpc_python_plugin for Python bindings
node + npm TypeScript generators

Versioning

info.codefly.yaml carries the image version (0.0.10 at time of writing). Bump via scripts/tag.sh — same convention as every other companion. Both the Dockerfile build and the Nix build read this value so the tag stays consistent.

Documentation

Index

Constants

View Source
const InfoConfigurationName = "info.codefly.yaml"

Variables

This section is empty.

Functions

func CompanionImage

func CompanionImage(ctx context.Context) (*resources.DockerImage, error)

func CreateBufConfiguration

func CreateBufConfiguration(ctx context.Context, bufDir string, service string, language languages.Language) error

func GenerateGRPC

func GenerateGRPC(ctx context.Context, language languages.Language, destination string, service string, endpoints ...*basev0.Endpoint) error

GenerateGRPC runs buf in a companion (Docker/Nix/local via golden wrapper) to generate gRPC client code for the given language and endpoints.

func GenerateOpenAPI

func GenerateOpenAPI(ctx context.Context, language languages.Language, destination string, _ string, endpoints ...*basev0.Endpoint) error

GenerateOpenAPI runs the OpenAPI generator in a companion (golden wrapper) to produce client code for the given language.

Types

type Buf added in v0.1.83

type Buf struct {
	Dir string
	// contains filtered or unexported fields
}

func NewBuf added in v0.1.83

func NewBuf(ctx context.Context, dir string) (*Buf, error)

func (*Buf) Generate added in v0.1.83

func (g *Buf) Generate(ctx context.Context) error

Generate runs buf in a companion (golden wrapper) to regenerate code from local proto files.

func (*Buf) WithCache added in v0.1.83

func (g *Buf) WithCache(location string)

type GoConfiguration

type GoConfiguration struct {
	Destination     string
	GoPackagePrefix string
}

type Info

type Info struct {
	Version string `yaml:"version"`
}

type PythonConfiguration added in v0.1.139

type PythonConfiguration struct {
	Destination string
}

type TypeScriptConfiguration added in v0.1.155

type TypeScriptConfiguration struct {
	Destination string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL