Documentation ¶
Overview ¶
Package bufconfig contains the configuration functionality.
Index ¶
- Constants
- func ConfigExists(ctx context.Context, readBucket storage.ReadBucket) (bool, error)
- func WriteConfig(ctx context.Context, writeBucket storage.WriteBucket, ...) error
- type Config
- type Provider
- type ReadConfigOption
- type WriteConfigOption
- func WriteConfigWithDependencyModuleReferences(dependencyModuleReferences ...bufmodule.ModuleReference) WriteConfigOption
- func WriteConfigWithDocumentationComments() WriteConfigOption
- func WriteConfigWithModuleIdentity(moduleIdentity bufmodule.ModuleIdentity) WriteConfigOption
- func WriteConfigWithUncomment() WriteConfigOption
Constants ¶
const ConfigFilePath = "buf.yaml"
ConfigFilePath is the configuration file path.
Variables ¶
This section is empty.
Functions ¶
func ConfigExists ¶ added in v0.25.0
ConfigExists checks if a configuration file exists.
func WriteConfig ¶ added in v0.34.0
func WriteConfig( ctx context.Context, writeBucket storage.WriteBucket, options ...WriteConfigOption, ) error
WriteConfig writes an initial configuration file into the bucket.
Types ¶
type Config ¶
type Config struct { ModuleIdentity bufmodule.ModuleIdentity Build *bufmodulebuild.Config Breaking *bufbreaking.Config Lint *buflint.Config }
Config is the user config.
func ReadConfig ¶ added in v0.27.0
func ReadConfig( ctx context.Context, provider Provider, readBucket storage.ReadBucket, options ...ReadConfigOption, ) (*Config, error)
ReadConfig reads the configuration, including potentially reading from the OS for an override.
Only use in CLI tools.
type Provider ¶
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 ¶
NewProvider returns a new Provider.
type ReadConfigOption ¶ added in v0.34.0
type ReadConfigOption func(*readConfigOptions)
ReadConfigOption is an option for ReadConfig.
func ReadConfigWithOverride ¶ added in v0.34.0
func ReadConfigWithOverride(override string) ReadConfigOption
ReadConfigWithOverride sets the override.
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.
If no override is set, this reads ConfigFilePath in the bucket..
type WriteConfigOption ¶ added in v0.34.0
type WriteConfigOption func(*writeConfigOptions)
WriteConfigOption is an option for WriteConfig.
func WriteConfigWithDependencyModuleReferences ¶ added in v0.34.0
func WriteConfigWithDependencyModuleReferences(dependencyModuleReferences ...bufmodule.ModuleReference) WriteConfigOption
WriteConfigWithDependencyModuleReferences returns a new WriteConfigOption that sets the dependencies of the module.
The default is to not have any dependencies.
If this option is used, WriteConfigWithModuleIdentity must also be used.
func WriteConfigWithDocumentationComments ¶ added in v0.34.0
func WriteConfigWithDocumentationComments() WriteConfigOption
WriteConfigWithDocumentationComments returns a new WriteConfigOption that documents the resulting configuration file.
func WriteConfigWithModuleIdentity ¶ added in v0.34.0
func WriteConfigWithModuleIdentity(moduleIdentity bufmodule.ModuleIdentity) WriteConfigOption
WriteConfigWithModuleIdentity returns a new WriteConfigOption that sets the name of the module to the given ModuleIdentity.
The default is to not set the name.
func WriteConfigWithUncomment ¶ added in v0.34.0
func WriteConfigWithUncomment() WriteConfigOption
WriteConfigWithUncomment returns a new WriteConfigOption that uncomments the resulting configuration file options that are commented out by default.
If this option is used, WriteConfigWithDocumentationComments must also be used.