buf: github.com/bufbuild/buf/internal/buf/bufconfig Index | Files

package bufconfig

import "github.com/bufbuild/buf/internal/buf/bufconfig"

Package bufconfig contains the configuration functionality.

Index

Package Files

bufconfig.go provider.go

Constants

const ConfigFilePath = "buf.yaml"

ConfigFilePath is the configuration file path.

func ConfigExists Uses

func ConfigExists(ctx context.Context, readBucket storage.ReadBucket) (bool, error)

ConfigExists checks if a configuration file exists.

func CreateConfig Uses

func CreateConfig(ctx context.Context, writeBucket storage.WriteBucket, name string, deps ...string) error

CreateConfig writes an initial configuration file into the bucket.

type Config Uses

type Config struct {
    Name     bufmodule.ModuleName
    Build    *bufmodulebuild.Config
    Breaking *bufbreaking.Config
    Lint     *buflint.Config
}

Config is the user config.

func ReadConfig Uses

func ReadConfig(ctx context.Context, provider Provider, readBucket storage.ReadBucket, override string) (*Config, error)

ReadConfig reads the configuration, including potentially reading from the OS for an override.

If no override is set, this reads ConfigFilePath in the bucket.. If override is set, this will first check if the override ends in .json or .yaml, if so, this reads the file at this path and uses it. Otherwise, this assumes this is configuration data in either JSON or YAML format, and unmarshals it.

Only use in CLI tools.

type Provider Uses

type Provider interface {
    // GetConfig gets the Config for the YAML data at ConfigFilePath.
    //
    // If the data is of length 0, returns the default config.
    GetConfig(ctx context.Context, readBucket storage.ReadBucket) (*Config, error)
    // GetConfig gets the Config for the given JSON or YAML data.
    //
    // If the data is of length 0, returns the default config.
    GetConfigForData(ctx context.Context, data []byte) (*Config, error)
}

Provider is a provider.

func NewProvider Uses

func NewProvider(logger *zap.Logger) Provider

NewProvider returns a new Provider.

Package bufconfig imports 14 packages (graph) and is imported by 1 packages. Updated 2020-10-20. Refresh now. Tools for package owners.