config

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileName = "easyp.yaml"
)

Default configurations.

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakingCheck

type BreakingCheck struct {
	Ignore []string `json:"ignore" yaml:"ignore"`
	// git ref to compare with
	AgainstGitRef string `json:"against_git_ref" yaml:"against_git_ref"`
}

BreakingCheck is the configuration for `breaking` command

type Config

type Config struct {
	// LintConfig is the lint configuration.
	Lint LintConfig `json:"lint" yaml:"lint"`

	// Deps is the dependencies repositories
	Deps []string `json:"deps" yaml:"deps"`

	// Generate is the generate configuration.
	Generate Generate `json:"generate" yaml:"generate"`

	// BreakingCheck `breaking` command's configuration
	BreakingCheck BreakingCheck `json:"breaking" yaml:"breaking"`
}

Config is the configuration of easyp.

func New

func New(_ context.Context, filepath string) (*Config, error)

New creates a new configuration from the file.

func (*Config) Validate added in v0.8.0

func (c *Config) Validate() error

Validate validates the configuration.

type Generate

type Generate struct {
	Inputs  []Input     `json:"inputs" yaml:"inputs"`
	Plugins []Plugin    `json:"plugins" yaml:"plugins"`
	Managed ManagedMode `json:"managed,omitempty" yaml:"managed,omitempty"`
}

Generate is the configuration of the generate command.

type Input

type Input struct {
	InputFilesDir InputFilesDir `yaml:"directory"`
	GitRepo       InputGitRepo  `yaml:"git_repo"`
}

Input source for generating code.

type InputDirectory

type InputDirectory struct {
	Path string `yaml:"path"`
}

InputDirectory is the configuration of the directory.

type InputFilesDir added in v0.7.12

type InputFilesDir struct {
	Path string `yaml:"path"`
	Root string `yaml:"root"`
}

InputFilesDir is the configuration of the directory with additional functionality.

func (*InputFilesDir) UnmarshalYAML added in v0.7.12

func (d *InputFilesDir) UnmarshalYAML(value *yaml.Node) error

type InputGitRepo

type InputGitRepo struct {
	URL          string `yaml:"url"`
	SubDirectory string `yaml:"sub_directory"`
	Out          string `yaml:"out"`
	Root         string `yaml:"root"`
}

InputGitRepo is the configuration of the git repository.

type LintConfig

type LintConfig struct {
	Use                 []string            `json:"use" yaml:"use" env:"USE"`                                                          // Use rules for linter.
	EnumZeroValueSuffix string              `json:"enum_zero_value_suffix" yaml:"enum_zero_value_suffix" env:"ENUM_ZERO_VALUE_SUFFIX"` // Enum zero value suffix.
	ServiceSuffix       string              `json:"service_suffix" yaml:"service_suffix" env:"SERVICE_SUFFIX"`                         // Service suffix.
	Ignore              []string            `json:"ignore" yaml:"ignore" env:"IGNORE"`                                                 // Ignore dirs with proto file.
	Except              []string            `json:"except" yaml:"except" env:"EXCEPT"`                                                 // Except linter rules.
	AllowCommentIgnores bool                `json:"allow_comment_ignores" yaml:"allow_comment_ignores" env:"ALLOW_COMMENT_IGNORES"`    // Allow comment ignore.
	IgnoreOnly          map[string][]string `json:"ignore_only" yaml:"ignore_only" env:"IGNORE_ONLY"`
}

LintConfig contains linter configuration.

type ManagedDisableRule added in v0.11.0

type ManagedDisableRule struct {
	// Module disables managed mode for all files in the specified module.
	Module string `json:"module,omitempty" yaml:"module,omitempty"`
	// Path disables managed mode for files matching the specified path (directory or file).
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// FileOption disables a specific file option from being modified.
	FileOption string `json:"file_option,omitempty" yaml:"file_option,omitempty"`
	// FieldOption disables a specific field option from being modified.
	FieldOption string `json:"field_option,omitempty" yaml:"field_option,omitempty"`
	// Field disables a specific field (fully qualified name: package.Message.field).
	Field string `json:"field,omitempty" yaml:"field,omitempty"`
}

ManagedDisableRule defines a rule to disable managed mode for specific conditions.

func (*ManagedDisableRule) Validate added in v0.11.0

func (r *ManagedDisableRule) Validate() error

Validate validates a disable rule.

type ManagedMode added in v0.11.0

type ManagedMode struct {
	// Enabled activates managed mode.
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Disable contains rules to disable managed mode for specific conditions.
	Disable []ManagedDisableRule `json:"disable,omitempty" yaml:"disable,omitempty"`
	// Override contains rules to override file and field options.
	Override []ManagedOverrideRule `json:"override,omitempty" yaml:"override,omitempty"`
}

ManagedMode is the configuration for managed mode which automatically sets file and field options without modifying the original proto files.

func (*ManagedMode) Validate added in v0.11.0

func (m *ManagedMode) Validate() error

Validate validates the managed mode configuration.

type ManagedOverrideRule added in v0.11.0

type ManagedOverrideRule struct {
	// FileOption specifies which file option to override.
	FileOption string `json:"file_option,omitempty" yaml:"file_option,omitempty"`
	// FieldOption specifies which field option to override.
	FieldOption string `json:"field_option,omitempty" yaml:"field_option,omitempty"`
	// Value is the value to set for the option.
	Value any `json:"value,omitempty" yaml:"value,omitempty"`
	// Module applies this override only to files in the specified module.
	Module string `json:"module,omitempty" yaml:"module,omitempty"`
	// Path applies this override only to files matching the specified path.
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// Field applies this override only to the specified field (fully qualified name).
	Field string `json:"field,omitempty" yaml:"field,omitempty"`
}

ManagedOverrideRule defines a rule to override file or field options.

func (*ManagedOverrideRule) Validate added in v0.11.0

func (r *ManagedOverrideRule) Validate() error

Validate validates an override rule.

type Plugin

type Plugin struct {
	Name    string   `json:"name,omitempty" yaml:"name,omitempty"`
	Remote  string   `json:"remote,omitempty" yaml:"remote,omitempty"`
	Path    string   `json:"path,omitempty" yaml:"path,omitempty"`
	Command []string `json:"command,omitempty" yaml:"command,omitempty"`

	Out         string            `json:"out" yaml:"out"`
	Opts        map[string]string `json:"opts,omitempty" yaml:"opts,omitempty"`
	WithImports bool              `json:"with_imports,omitempty" yaml:"with_imports,omitempty"`
}

Plugin is the configuration of the plugin.

Jump to

Keyboard shortcuts

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