Reference
stubs.yaml and buf.yaml
stubs.yaml configures a workspace: the modules in it, what they depend on, and how they're linted and checked for
breaking changes. buf.yaml has the same format, and stubs reads it as it is; when a directory has both, stubs
uses stubs.yaml. stubs init writes a new one.
version: v2
modules:
- path: proto
name: stubs.dev/acme/payments
deps:
- stubs.dev/acme/common
lint:
use:
- STANDARD
breaking:
use:
- FILEversion
The format: v2. stubs also reads v1 and v1beta1 files, which describe a single module; stubs config migrate
rewrites them as v2. Required.
name
A shorthand for a workspace that is one module at its root: the module's name, as on modules[].name. It can't be used
together with modules.
modules
The workspace's modules, each a directory of .proto files. Without modules, the workspace is one module at ..
Paths in the workspace are relative to the file.
modules:
- path: proto/payments
name: stubs.dev/acme/payments
- path: proto/common
name: stubs.dev/acme/common
excludes:
- proto/common/internalA module's own lint and breaking sections replace the workspace's for that module; they aren't merged.
path
The module's directory, relative to the workspace. Every .proto file under it is in the module, unless includes or
excludes say otherwise. Defaults to ..
name
The module's name on a registry: the registry's host, an owner and the module's name, as in
stubs.dev/acme/payments. A module needs one to be pushed, or to be depended on by name.
includes
Directories under path to take files from; files outside them are left out. When it's not set, every directory is
included.
excludes
Directories under path to leave out. Each must be inside one of includes when both are set.
deps
The modules the workspace's modules import, by name. Name a label or a commit after a colon to use that version, as in
stubs.dev/acme/common:v1; without one, stubs dep update takes the module's default label. The exact commits are
pinned in stubs.lock.
deps:
- stubs.dev/acme/common
- stubs.dev/acme/money:v1lint
How stubs lint checks the workspace's modules. Without it, the STANDARD rules are used. The rules and categories
are on Lint rules.
lint:
use:
- STANDARD
except:
- FIELD_NOT_REQUIRED
ignore_only:
ENUM_ZERO_VALUE_SUFFIX:
- proto/legacy
enum_zero_value_suffix: _NONE| Key | What it does | Default |
|---|---|---|
use | Categories and rule IDs to check. | STANDARD |
except | Categories and rule IDs to leave out of use. | none |
ignore | Files and directories no lint rule checks, relative to the workspace. | none |
ignore_only | Rule IDs or categories, each with the files and directories it doesn't check. | none |
disallow_comment_ignores | true stops // buf:lint:ignore RULE_ID comments in .proto files from silencing a rule. | false |
enum_zero_value_suffix | The suffix ENUM_ZERO_VALUE_SUFFIX asks of an enum's zero value. | _UNSPECIFIED |
rpc_allow_same_request_response | true lets an RPC use one message as both its request and response. | false |
rpc_allow_google_protobuf_empty_requests | true lets an RPC take google.protobuf.Empty. | false |
rpc_allow_google_protobuf_empty_responses | true lets an RPC return google.protobuf.Empty. | false |
service_suffix | The suffix SERVICE_SUFFIX asks of a service's name. | Service |
disable_builtin | true turns off the built-in rules, leaving only those of plugins. | false |
breaking
How stubs breaking compares the workspace with an earlier version. Without it, the FILE rules are used. The rules
and categories are on Breaking-change rules.
breaking:
use:
- FILE
ignore_unstable_packages: true| Key | What it does | Default |
|---|---|---|
use | Categories and rule IDs to check. | FILE |
except | Categories and rule IDs to leave out of use. Rarely what you want: a breaking change is still one. | none |
ignore | Files and directories no rule checks, relative to the workspace. | none |
ignore_only | Rule IDs or categories, each with the files and directories it doesn't check. | none |
ignore_unstable_packages | true skips packages whose last part is an unstable version, such as v1alpha1, v1beta1 or v1test. | false |
disable_builtin | true turns off the built-in rules, leaving only those of plugins. | false |
plugins
Check plugins: programs that add their own lint or breaking-change rules. Each entry has a plugin, the program's
name on your PATH or its path (or a list of the program and its arguments), and optional options passed to it.
Their rules are used and excepted by ID like the built-in ones.
plugins:
- plugin: protoc-gen-acme-lint
options:
max_fields: 50Stubs doesn't host check plugins yet, so they're local programs.
policies
Policy files to check the workspace against: shared lint and breaking-change settings, written as
buf.policy.yaml. Each entry has a policy, the file's path, and its own ignore and
ignore_only, as in lint and breaking.
policies:
- policy: policies/acme.policy.yaml
ignore:
- proto/legacyStubs doesn't host policy files yet, so they're local files. Organisations can also set policies on the registry itself, which every push is checked against (see Governance).