buf: github.com/bufbuild/buf/internal/buf/bufcore/bufmodule/bufmodulebuild Index | Files

package bufmodulebuild

import "github.com/bufbuild/buf/internal/buf/bufcore/bufmodule/bufmodulebuild"

Index

Package Files

bufmodulebuild.go config.go module_bucket_builder.go module_file_set_builder.go module_include_builder.go util.go

type BuildOption Uses

type BuildOption func(*buildOptions)

BuildOption is an option for BuildForBucket.

func WithPaths Uses

func WithPaths(paths []string) BuildOption

WithPaths returns a new BuildOption that specifies specific file or directory paths to build.

These paths must exist. These paths must be relative to the bucket or include directory paths. These paths will be normalized. Multiple calls to this option and WithPathsAllowNotExist will override previous calls.

This results in ModuleWithTargetPaths being used on the resulting build module. This is done within bufmodulebuild so we can resolve the paths relative to their roots.

func WithPathsAllowNotExist Uses

func WithPathsAllowNotExist(paths []string) BuildOption

WithPathsAllowNotExist returns a new BuildOption that specifies specific file or directory paths to build, but allows the specified paths to not exist.

These paths must exist. These paths must be relative to the bucket or include directory paths. These paths will be normalized. Multiple calls to this option and WithPaths will override previous calls.

This results in ModuleWithTargetPathsAllowNotExist being used on the resulting build module. This is done within bufmodulebuild so we can resolve the paths relative to their roots.

type Config Uses

type Config struct {
    // RootToExcludes contains a map from root to the excludes for that root.
    //
    // Roots are the root directories within a bucket to search for Protobuf files.
    //
    // There will be no between the roots, ie foo/bar and foo are not allowed.
    // All Protobuf files must be unique relative to the roots, ie if foo and bar
    // are roots, then foo/baz.proto and bar/baz.proto are not allowed.
    //
    // All roots will be normalized and validated.
    //
    // Excludes are the directories within a bucket to exclude.
    //
    // There should be no overlap between the excludes, ie foo/bar and foo are not allowed.
    //
    // All excludes must reside within a root, but none will be equal to a root.
    // All excludes will be normalized and validated.
    // The excludes in this map will be relative to the root they map to!
    //
    // If RootToExcludes is empty, the default is "." with no excludes.
    RootToExcludes map[string][]string
    // Resolved or unresolved
    Deps []bufmodule.ModuleName
}

Config is a configuration for build.

func NewConfigV1Beta1 Uses

func NewConfigV1Beta1(externalConfig ExternalConfigV1Beta1, deps ...string) (*Config, error)

NewConfigV1Beta1 returns a new, validated Config for the ExternalConfig.

type ExternalConfigV1Beta1 Uses

type ExternalConfigV1Beta1 struct {
    Roots    []string `json:"roots,omitempty" yaml:"roots,omitempty"`
    Excludes []string `json:"excludes,omitempty" yaml:"excludes,omitempty"`
}

ExternalConfigV1Beta1 is an external config.

type ModuleBucketBuilder Uses

type ModuleBucketBuilder interface {
    // BuildForBucket builds a module for the given bucket.
    //
    // If paths is empty, all files are built.
    // Paths should be relative to the bucket, not the roots.
    BuildForBucket(
        ctx context.Context,
        readBucket storage.ReadBucket,
        config *Config,
        options ...BuildOption,
    ) (bufmodule.Module, error)
}

ModuleBucketBuilder builds modules for buckets.

func NewModuleBucketBuilder Uses

func NewModuleBucketBuilder(logger *zap.Logger) ModuleBucketBuilder

NewModuleBucketBuilder returns a new BucketBuilder.

type ModuleFileSetBuilder Uses

type ModuleFileSetBuilder interface {
    Build(
        ctx context.Context,
        module bufmodule.Module,
    ) (bufmodule.ModuleFileSet, error)
}

ModuleFileSetBuilder builds ModuleFileSets from Modules.

func NewModuleFileSetBuilder Uses

func NewModuleFileSetBuilder(
    logger *zap.Logger,
    moduleReader bufmodule.ModuleReader,
) ModuleFileSetBuilder

NewModuleFileSetBuilder returns a new ModuleSetProvider.

type ModuleIncludeBuilder Uses

type ModuleIncludeBuilder interface {
    // BuildForIncludes builds a module for the given includes and file paths.
    BuildForIncludes(
        ctx context.Context,
        includeDirPaths []string,
        options ...BuildOption,
    ) (bufmodule.Module, error)
}

ModuleIncludeBuilder builds modules for includes.

This is used for protoc.

func NewModuleIncludeBuilder Uses

func NewModuleIncludeBuilder(
    logger *zap.Logger,
    storageosProvider storageos.Provider,
) ModuleIncludeBuilder

NewModuleIncludeBuilder returns a new ModuleIncludeBuilder.

TODO: we should parse includeDirPaths for modules as well in theory would be nice to be able to do buf protoc -I path/to/dir -I buf.build/foo/bar/v1

Package bufmodulebuild imports 12 packages (graph) and is imported by 5 packages. Updated 2020-11-28. Refresh now. Tools for package owners.