Documentation
¶
Index ¶
- Variables
- func Register(cfg *Config)
- func Unregister()
- type Config
- type OSGitBranchReader
- type Rule
- type RuleType
- type VersionValidator
- type VersionValidatorPlugin
- func (p *VersionValidatorPlugin) Description() string
- func (p *VersionValidatorPlugin) GetConfig() *Config
- func (p *VersionValidatorPlugin) IsEnabled() bool
- func (p *VersionValidatorPlugin) Name() string
- func (p *VersionValidatorPlugin) Validate(newVersion, previousVersion semver.SemVersion, bumpType string) error
- func (p *VersionValidatorPlugin) ValidateSet(version semver.SemVersion) error
- func (p *VersionValidatorPlugin) Version() string
Constants ¶
This section is empty.
Variables ¶
var GetVersionValidatorFn = func() VersionValidator {
return defaultVersionValidator
}
GetVersionValidatorFn allows overriding the getter function for testing.
var RegisterVersionValidatorFn = func(v VersionValidator) {
defaultVersionValidator = v
}
RegisterVersionValidatorFn allows overriding the registration function for testing.
Functions ¶
Types ¶
type Config ¶
Config holds the configuration for the version validator plugin.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration for the version validator.
type OSGitBranchReader ¶
type OSGitBranchReader struct{}
OSGitBranchReader implements core.GitBranchReader using actual git commands.
func NewOSGitBranchReader ¶
func NewOSGitBranchReader() *OSGitBranchReader
NewOSGitBranchReader creates a new OSGitBranchReader.
func (*OSGitBranchReader) GetCurrentBranch ¶
func (g *OSGitBranchReader) GetCurrentBranch(ctx context.Context) (string, error)
GetCurrentBranch returns the current git branch name.
type Rule ¶
type Rule struct {
Type RuleType `yaml:"type"`
Pattern string `yaml:"pattern,omitempty"`
Value int `yaml:"value,omitempty"`
Enabled bool `yaml:"enabled,omitempty"`
Branch string `yaml:"branch,omitempty"`
Allowed []string `yaml:"allowed,omitempty"`
}
Rule represents a single validation rule.
type RuleType ¶
type RuleType string
RuleType defines the type of validation rule.
const ( RulePreReleaseFormat RuleType = "pre-release-format" RuleMajorVersionMax RuleType = "major-version-max" RuleMinorVersionMax RuleType = "minor-version-max" RulePatchVersionMax RuleType = "patch-version-max" RuleRequirePreRelease0x RuleType = "require-pre-release-for-0x" RuleBranchConstraint RuleType = "branch-constraint" RuleNoMajorBump RuleType = "no-major-bump" RuleNoMinorBump RuleType = "no-minor-bump" RuleNoPatchBump RuleType = "no-patch-bump" RuleMaxPreReleaseIter RuleType = "max-prerelease-iterations" RuleRequireEvenMinor RuleType = "require-even-minor" )
type VersionValidator ¶
type VersionValidator interface {
Name() string
Description() string
Version() string
Validate(newVersion, previousVersion semver.SemVersion, bumpType string) error
ValidateSet(version semver.SemVersion) error
}
VersionValidator defines the interface for version validation plugins.
type VersionValidatorPlugin ¶
type VersionValidatorPlugin struct {
// contains filtered or unexported fields
}
VersionValidatorPlugin implements the VersionValidator interface.
func NewVersionValidator ¶
func NewVersionValidator(cfg *Config) *VersionValidatorPlugin
NewVersionValidator creates a new VersionValidatorPlugin instance.
func (*VersionValidatorPlugin) Description ¶
func (p *VersionValidatorPlugin) Description() string
Description returns a brief description of the plugin.
func (*VersionValidatorPlugin) GetConfig ¶
func (p *VersionValidatorPlugin) GetConfig() *Config
GetConfig returns the plugin configuration.
func (*VersionValidatorPlugin) IsEnabled ¶
func (p *VersionValidatorPlugin) IsEnabled() bool
IsEnabled returns true if the plugin is enabled.
func (*VersionValidatorPlugin) Name ¶
func (p *VersionValidatorPlugin) Name() string
Name returns the plugin name.
func (*VersionValidatorPlugin) Validate ¶
func (p *VersionValidatorPlugin) Validate(newVersion, previousVersion semver.SemVersion, bumpType string) error
Validate checks if the version transition is valid according to configured rules.
func (*VersionValidatorPlugin) ValidateSet ¶
func (p *VersionValidatorPlugin) ValidateSet(version semver.SemVersion) error
ValidateSet checks if a manually set version is valid according to configured rules.
func (*VersionValidatorPlugin) Version ¶
func (p *VersionValidatorPlugin) Version() string
Version returns the plugin version.