bufgen

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 32 Imported by: 4

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 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.

func GenerateWithDeleteOuts added in v1.35.0

func GenerateWithDeleteOuts(deleteOuts bool) GenerateOption

GenerateWithDeleteOuts returns a new GenerateOption that results in the output directories, zip files, or jar files being deleted before generation is run.

func GenerateWithIncludeImportsOverride added in v1.32.0

func GenerateWithIncludeImportsOverride(includeImports bool) GenerateOption

GenerateWithIncludeImportsOverride is a strict override on whether imports are generated. This overrides IncludeImports from the GeneratePluginConfig.

This option has presence, i.e. setting this option to false is not the same as not setting it, as the latter does not override the config.

Note that this does NOT result in the Well-Known Types being generated when set to true, use GenerateWithIncludeWellKnownTypes to include the Well-Known Types.

func GenerateWithIncludeWellKnownTypesOverride added in v1.32.0

func GenerateWithIncludeWellKnownTypesOverride(includeWellKnownTypes bool) GenerateOption

GenerateWithIncludeWellKnownTypesOverride is a strict override on whether the well known types are generated. This overrides IncludeWKT from the GeneratePluginConfig.

This option has presence, i.e. setting this option to false is not the same as not setting it, as the latter does not override the config.

Setting this option to true has no effect if GenerateWithIncludeImports is not set to true.

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 bufconfig.GenerateConfig,
		images []bufimage.Image,
		options ...GenerateOption,
	) error
}

Generator generates Protobuf stubs based on configurations.

func NewGenerator

func NewGenerator(
	logger *zap.Logger,
	tracer tracing.Tracer,
	storageosProvider storageos.Provider,
	runner command.Runner,

	clientConfig *connectclient.Config,
) Generator

NewGenerator returns a new Generator.

type Strategy

type Strategy int

Strategy is a generation stategy.

const (
	// StrategyDirectory is the strategy that says to generate per directory.
	//
	// This is the default value.
	StrategyDirectory Strategy = 1
	// StrategyAll is the strategy that says to generate with all files at once.
	StrategyAll Strategy = 2
)

func ParseStrategy

func ParseStrategy(s string) (Strategy, error)

ParseStrategy parses the Strategy.

If the empty string is provided, this is interpreted as StrategyDirectory.

func (Strategy) String

func (s Strategy) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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