bufgen

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package bufgen does configuration-based generation.

It is used by the buf generate command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Required
	PluginConfigs []*PluginConfig
}

Config is a configuration.

func ReadConfig

func ReadConfig(fileOrData string) (*Config, error)

ReadConfig reads the configuration from the OS.

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 ExternalConfigV1Beta1

type ExternalConfigV1Beta1 struct {
	Version string                        `json:"version,omitempty" yaml:"version,omitempty"`
	Plugins []ExternalPluginConfigV1Beta1 `json:"plugins,omitempty" yaml:"plugins,omitempty"`
}

ExternalConfigV1Beta1 is an external configuration.

Only use outside of this package for testing.

type ExternalPluginConfigV1Beta1

type ExternalPluginConfigV1Beta1 struct {
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	Out  string `json:"out,omitempty" yaml:"out,omitempty"`
	Opt  string `json:"opt,omitempty" yaml:"opt,omitempty"`
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

ExternalPluginConfigV1Beta1 is an external plugin configuration.

Only use outside of this package for testing.

type GenerateOption

type GenerateOption func(*generateOptions)

GenerateOption is an option for Generate.

func GenerateWithBaseOutDirPath

func GenerateWithBaseOutDirPath(baseOutDirPath string) GenerateOption

GenerateWithBaseOutDirPath returns a new GenerateOption that uses the given base directory as the output directory.

The default is to use the current directory.

type Generator

type Generator interface {
	// Generate calls the generation logic.
	//
	// The config is assumed to be valid. If created by ReadConfig, it will
	// always be valid.
	Generate(
		ctx context.Context,
		container app.EnvStdioContainer,
		config *Config,
		image bufimage.Image,
		options ...GenerateOption,
	) error
}

Generator generates Protobuf stubs based on configurations.

func NewGenerator

func NewGenerator(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
) Generator

NewGenerator returns a new Generator.

type PluginConfig

type PluginConfig struct {
	// Required
	Name string
	// Required
	Out string
	// Optional
	Opt string
	// Optional
	Path string
}

PluginConfig is a plugin configuration.

Jump to

Keyboard shortcuts

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