bufsync

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bufsync plans upgrades to the versions buf.gen.yaml pins: remote plugin versions and git input tags. A git input whose repository a go.mod requires as a module follows that module's version instead of a policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCommand

func GenerateCommand(template string) (string, []string)

GenerateCommand returns the directory and command that regenerate template's output.

func LinkedPolicy added in v0.21.3

func LinkedPolicy(links []Link, policies map[string]string) error

LinkedPolicy fails on a policy that names a linked input, which follows go.mod instead.

Types

type Link struct {
	// Change moves the tag to the required version.
	Change edit.Change
	// Key is the input's git_repo, which buf.policies keys it by.
	Key string
	// Module is the Go module path, such as github.com/acme/protos.
	Module string
	// Required is the release go.mod builds against, the highest when several go.mod files
	// require the module directly.
	Required string
}

Link is a git input tag that follows the version a go.mod requires of the same repository.

func (Link) Drift added in v0.24.0

func (l Link) Drift() string

Drift describes how l's tag differs from the version go.mod builds against, or "" when it matches.

func (Link) Moves added in v0.21.3

func (l Link) Moves() bool

Moves reports whether the link rewrites its tag.

func (Link) On added in v0.21.3

func (l Link) On(c edit.Change) bool

On reports whether c rewrites the link's tag.

func (Link) PolicyError added in v0.24.0

func (l Link) PolicyError(policies map[string]string) error

PolicyError reports a policy set on l, which takes none, since it follows its module in go.mod.

type Plan

type Plan struct {
	Changes []edit.Change
	// AllTemplates lists every buf.gen file, all regenerated when buf dep update changes a
	// buf.lock, since a template can generate from a module whose deps just moved.
	AllTemplates []string
	// DepModules lists the directories whose buf.yaml declares deps, for buf dep update.
	DepModules []string
	// Links lists the git inputs that follow a Go module, as go.mod stood when the plan was
	// made. Planner.Links resolves them again once the Go upgrade has run.
	Links    []Link
	Warnings []string
}

Plan is every change a buf upgrade makes, resolved before any file is written.

func (Plan) With added in v0.21.3

func (p Plan) With(links []Link) ([]edit.Change, []string)

With returns the plan's changes plus each link that moves, sorted by file and line, and the templates they touch. A link drops any planned change on its span, since an input the Go upgrade linked after planning now follows go.mod, even where go.mod leaves the tag in place.

type Planner

type Planner struct {
	// Root is the repository directory.
	Root string
	// Policies maps a remote plugin name or a git_repo URL to a policy name. Unlisted entries
	// use latest.
	Policies map[string]string
	Registry Registry
	Run      Runner
	// Timeout bounds each git tag listing. Zero leaves it unbounded.
	Timeout time.Duration
	// ListFiles returns the candidate files relative to Root. Nil uses pins.GitFiles.
	ListFiles func(root string) ([]string, error)
	// GoExclude lists the globs dependencies.go.exclude names. A go.mod they match holds no
	// module a git input follows.
	GoExclude []string
}

Planner computes a Plan.

func (p Planner) Links() ([]Link, []string, error)

Links returns every git input that follows a Go module, resolved against the tree as it stands, so a call after the Go upgrade sees the versions it left. The warnings name inputs that match several modules, which link to none, and buf files it skipped as unparsable.

func (Planner) Plan

func (p Planner) Plan(ctx context.Context) (Plan, error)

Plan reads every buf.gen template and buf.yaml, then resolves each pin its policy lets move. It writes nothing, so any error leaves the repository untouched.

type Registry

type Registry interface {
	LatestPlugin(ctx context.Context, plugin string) (string, error)
}

Registry resolves the newest version of a remote plugin.

type Runner

type Runner interface {
	Output(ctx context.Context, dir string, env []string, name string, args ...string) ([]byte, error)
}

Runner runs a command and returns its stdout.

Jump to

Keyboard shortcuts

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