workspace

module
v0.0.0-...-5a27533 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0

README

Buf workspace example

You need to have the buf CLI installed to follow along with this example.

This directory provides an example of a Buf workspace that contains multiple Buf modules that are meant to be consumed as dependencies by other Protobuf projects. There are two modules in this workspace:

Both modules are available on the Buf Schema Registry:

Structure

The basic structure of this workspace:

.
├── buf.gen.yaml
├── buf.work.yaml
├── observabilityapi
│   ├── api
│   │   ├── v1
│   │   │   └── api.proto
│   │   └── v2
│   │       └── api.proto
│   └── buf.yaml
└── observabilitytypes
    ├── buf.yaml
    ├── log
    │   ├── v1
    │   │   └── log.proto
    │   ├── v2
    │   │   └── log.proto
    │   └── v3
    │       └── log.proto
    └── metric
        └── v1
            └── metric.proto

The workspace configuration is defined in buf.work.yaml.

Linting

To lint all of the Buf modules in the workspace:

buf lint

To lint specific modules:

buf lint observabilityapi
buf lint observabilitytypes

Breaking change detection

To perform breaking change detection against the previous commit to the main branch of this repository:

buf breaking \
--against ../.git#branch=main,ref=HEAD~1,subdir=workspace

As with buf lint, buf breaking detects breaking changes amongst all modules. To target only a specific module:

buf breaking observabilitytypes \
--against ../.git#branch=main,ref=HEAD~1,subdir=workspace

In this case, the --against flag targets the root of this repository using ../.git and then this directory using subdir=workspace. In most projects, you would likely be able to use a more straightforward target, like this:

buf breaking observabilitytypes \
--against .git#branch=main,ref=HEAD~1

Code generation

To generate code stubs for all modules in the workspace using the plugins defined in buf.gen.yaml:

buf generate

To generate code stubs for specific modules:

buf generate observabilityapi
buf generate observabilitytypes

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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