bufmigrate

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffAll added in v1.32.0

func DiffAll(
	ctx context.Context,
	migrator Migrator,
	bucket storage.ReadBucket,
	writer io.Writer,
	ignoreDirPaths []string,
) error

DiffAll uses bufconfig.WalkFileInfos to discover all known module, workspace, and buf.gen.yaml paths in the Bucket, and diffs them.

ignoreDirPaths should be normalized and relative to the root of the bucket, if specified.

func MigrateAll added in v1.32.0

func MigrateAll(
	ctx context.Context,
	migrator Migrator,
	bucket storage.ReadWriteBucket,
	ignoreDirPaths []string,
) error

MigrateAll uses bufconfig.WalkFileInfos to discover all known module, workspace, and buf.gen.yaml paths in the Bucket, and migrates them.

ignoreDirPaths should be normalized and relative to the root of the bucket, if specified.

Types

type Migrator

type Migrator interface {
	// Migrate migrates buf configuration files.
	//
	// A buf.yaml v2 is written if any workspace directory or module directory is
	// specified. The modules directories in the buf.yaml v2 will contain:
	//
	//   - directories at moduleDirPaths
	//   - directories pointed to by buf.work.yamls at workspaceDirPaths
	//
	// More specifically:
	//
	//   - If a workspace is specified, then all of its module directories are also migrated,
	//     regardless whether these module directories are specified in moduleDirPaths. Same
	//     behavior with multiple workspaces. For example, if workspace foo has directories
	//     bar and baz, then specifying foo, foo + bar and foo + bar + baz are the same.
	//   - If a workspace is specfied, and modules not from this workspace are specified, the
	//     buf.yaml will contain all directories from the workspace, as well as the module
	//     directories specified.
	//   - If only module directories are specified, then the buf.yaml will contain exactly
	//     these directories.
	//   - If a module specified is within some workspace not from workspaceDirPaths, we migrate
	//     the module directory only (updating/deciding on this behavior is still a todo).
	//   - If only one workspace directory is specified and no module directory is specified,
	//     the buf.yaml will be written at <workspace directory>/buf.yaml. Otherwise, it will
	//     be written at ./buf.yaml.
	//
	// Each generation template will be overwritten by a file in v2.
	Migrate(
		ctx context.Context,
		bucket storage.ReadWriteBucket,
		workspaceDirPaths []string,
		moduleDirPaths []string,
		bufGenYAMLFilePaths []string,
	) error
	// Diff runs migrate, but produces a diff instead of writing the migration.
	Diff(
		ctx context.Context,
		bucket storage.ReadBucket,
		writer io.Writer,
		workspaceDirPaths []string,
		moduleDirPaths []string,
		bufGenYAMLFilePaths []string,
	) error
}

Migrator migrates buf configuration files.

func NewMigrator added in v1.32.0

func NewMigrator(
	logger *zap.Logger,
	runner command.Runner,
	moduleKeyProvider bufmodule.ModuleKeyProvider,
	commitProvider bufmodule.CommitProvider,
) Migrator

Jump to

Keyboard shortcuts

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