bufbuild_helper

package module
v0.0.0-...-c89aeb8 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

BufBuild Helper

This package aims to parse and generate associated files for https://buf.build service.

Buf provides a great CLI to accomplish most of the works, and they also document the detailed instructions at https://docs.buf.build/configuration/v1/buf-yaml.

While some use case requires configuration files to be processed in the runtime.

Following files are supported,

  • buf.yaml - v1
  • buf.work.yaml - v1
  • buf.lock - v1
  • buf.gen.yaml -v1

NOTE

We primarily use this helper for some internal tools, and some breaking changes may be applied at any time.

Documentation

Index

Constants

View Source
const (
	GenFileName = "buf.gen.yaml"
)
View Source
const (
	LockFileName = "buf.lock"
)
View Source
const (
	ModFileName = "buf.yaml"
)
View Source
const (
	WorkspaceFileName = "buf.work.yaml"
)

Variables

View Source
var (
	DefaultGenVersion = "v1"
	DefaultPlugins    = []*PluginPolicy{
		{
			Remote: "buf.build/library/plugins/go:v1.27.1-1",
			Out:    "gen/go",
			Opt:    []string{"paths=source_relative"},
		},
		{
			Remote: "buf.build/library/plugins/go-grpc:v1.1.0-2",
			Out:    "gen/go",
			Opt:    []string{"paths=source_relative", "require_unimplemented_servers=false"},
		},
	}
)
View Source
var (
	DefaultLockVersion   = "v1"
	DefaultLockCachePath = "/module/data"
	DefaultHomeCachePath = "/.cache/buf"
)
View Source
var (
	DefaultModVersion = "v1"
	DefaultLintPolicy = &LintPolicy{
		Use: []string{"DEFAULT"},
	}
	DefaultBreakingPolicy = &BreakingPolicy{
		Use: []string{"FILE"},
	}
)
View Source
var (
	DefaultWorkspaceVersion = "v1"
)

Functions

func AppendFileName

func AppendFileName(dir string, fileName string) string

func CheckModDepWithPin

func CheckModDepWithPin(mod string) (err error)

func Marshal

func Marshal(path string, in interface{}) (err error)

func ReadFile

func ReadFile(path string) (b []byte, err error)

func Unmarshal

func Unmarshal(expectedName, path string, out interface{}, unsafe bool) (err error)

Types

type BreakingPolicy

type BreakingPolicy struct {
	Use    []string `yaml:"use,omitempty"`
	Except []string `yaml:"except,omitempty"`
	Ignore []string `yaml:"ignore,omitempty"`
}

func ParseModBreakingPolicy

func ParseModBreakingPolicy(path string) (breaking *BreakingPolicy, err error)

type DepMetadata

type DepMetadata struct {
	Remote     string    `yaml:"remote" yaml:"remote"`
	Owner      string    `yaml:"owner" yaml:"owner"`
	Repository string    `yaml:"repository" yaml:"repository"`
	Branch     string    `yaml:"branch" yaml:"branch"`
	Commit     string    `yaml:"commit" yaml:"commit"`
	Digest     string    `yaml:"digest" yaml:"digest"`
	CreateTime time.Time `yaml:"create_time" yaml:"create_time"`
}

func (*DepMetadata) IsValid

func (m *DepMetadata) IsValid() bool

func (*DepMetadata) Resolve

func (m *DepMetadata) Resolve(str string)

type GenConfig

type GenConfig struct {
	Version string          `yaml:"version"`
	Plugins []*PluginPolicy `yaml:"plugins,omitempty"`
	Managed *ManagedPolicy  `yaml:"managed,omitempty"`
}

func (*GenConfig) Generate

func (cfg *GenConfig) Generate(dir string) (err error)

func (*GenConfig) Parse

func (cfg *GenConfig) Parse(path string) (err error)

func (*GenConfig) UnsafeParse

func (cfg *GenConfig) UnsafeParse(path string) (err error)

type GoPackageMetadata

type GoPackageMetadata struct {
	Default  string            `yaml:"default" yaml:"default"`
	Except   []string          `yaml:"except,omitempty" yaml:"except"`
	Override map[string]string `yaml:"override" yaml:"override"`
}

type LintPolicy

type LintPolicy struct {
	Use                 []string `yaml:"use,omitempty"`
	Except              []string `yaml:"except,omitempty"`
	Ignore              []string `yaml:"ignore,omitempty"`
	AllowCommentIgnores bool     `yaml:"allow_comment_ignores,omitempty"`
	EnumZeroValueSuffix string   `yaml:"enum_zero_value_suffix,omitempty"`
	ServiceSuffix       string   `yaml:"service_suffix,omitempty"`
}

func ParseModLintPolicy

func ParseModLintPolicy(path string) (lint *LintPolicy, err error)

type LockConfig

type LockConfig struct {
	Version string         `yaml:"version"`
	Deps    []*DepMetadata `yaml:"deps"`
}

func (*LockConfig) Generate

func (cfg *LockConfig) Generate(dir string) (err error)
func (cfg *LockConfig) Link(target string, dirs ...string) (err error)

Link looks up the buf module cache with specified commit hash, then it creates symbolic link to the target The built-in cache directories will be looked up in order by following https://docs.buf.build/bsr/overview#module-cache

func (*LockConfig) Parse

func (cfg *LockConfig) Parse(path string) (err error)

func (*LockConfig) UnsafeParse

func (cfg *LockConfig) UnsafeParse(path string) (err error)

type ManagedOptimizeType

type ManagedOptimizeType string
const (
	OptimizeSpeed       ManagedOptimizeType = "SPEED"
	OptimizeCodeSize    ManagedOptimizeType = "CODE_SIZE"
	OptimizeLiteRuntime ManagedOptimizeType = "LITE_RUNTIME"
)

type ManagedPolicy

type ManagedPolicy struct {
	Enabled             bool                `yaml:"enabled"`
	CCEnabledArenas     bool                `yaml:"cc_enabled_arenas"`
	JavaMultipleFiles   bool                `yaml:"java_multiple_files"`
	JavaPackagePrefix   string              `yaml:"java_package_prefix"`
	JavaStringCheckUtf8 bool                `yaml:"java_string_check_utf_8"`
	OptimizeFor         ManagedOptimizeType `yaml:"optimize_for"`
	GoPackagePrefix     *GoPackageMetadata  `yaml:"go_package_prefix,omitempty"`
}

func ParseGenManagedPolicy

func ParseGenManagedPolicy(path string) (managed *ManagedPolicy, err error)

type ModConfig

type ModConfig struct {
	Version  string          `yaml:"version"`
	Name     string          `yaml:"name,omitempty"`
	Deps     []string        `yaml:"deps,omitempty"`
	Lint     *LintPolicy     `yaml:"lint"`
	Breaking *BreakingPolicy `yaml:"breaking"`
}

func (*ModConfig) Generate

func (cfg *ModConfig) Generate(dir string) (err error)

func (*ModConfig) Parse

func (cfg *ModConfig) Parse(path string) (err error)

func (*ModConfig) UnsafeParse

func (cfg *ModConfig) UnsafeParse(path string) (err error)

type PluginPolicy

type PluginPolicy struct {
	Name     string   `yaml:"name,omitempty"`
	Remote   string   `yaml:"remote,omitempty"`
	Out      string   `yaml:"out,omitempty"`
	Path     string   `yaml:"path,omitempty"`
	Strategy string   `yaml:"strategy,omitempty"`
	Opt      []string `yaml:"opt,omitempty"`
}

func ParseGenPluginsPolicy

func ParseGenPluginsPolicy(path string) (plugins []*PluginPolicy, err error)

type WorkspaceConfig

type WorkspaceConfig struct {
	Version     string   `yaml:"version"`
	Directories []string `yaml:"directories"`
}

func (*WorkspaceConfig) Generate

func (cfg *WorkspaceConfig) Generate(dir string) (err error)

func (*WorkspaceConfig) Parse

func (cfg *WorkspaceConfig) Parse(path string) (err error)

func (*WorkspaceConfig) UnsafeParse

func (cfg *WorkspaceConfig) UnsafeParse(path string) (err error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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