rules

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRuleNotFound = errors.New("rule not found")

ErrRuleNotFound is returned when a rule is not found

Functions

This section is empty.

Types

type Name

type Name string
const (
	SemverMajor      Name = "semver-major"
	SemverMinor      Name = "semver-minor"
	SemverPatch      Name = "semver-patch"
	CalverMajor      Name = "calver-major"
	CalverMinor      Name = "calver-minor"
	CalverPatch      Name = "calver-patch"
	CalverPrerelease Name = "calver-prerelease"
	Regex            Name = "regex"
	Always           Name = "always"
)

func ParseRuleName

func ParseRuleName(name string) (Name, error)

ParseRuleName takes a rule name as a string and checks if it exists in the predefined rules. If the rule is found, it returns the corresponding Name and a nil error. If the rule is not found, it returns an empty Name and an error indicating that the rule was not found.

Parameters:

  • name: A string representing the name of the rule to be parsed.

Returns:

  • Name: The corresponding Name if found.
  • error: An error if the rule is not found.

func (Name) String

func (r Name) String() string

String returns the string representation of the rule name.

type RuleInterface

type RuleInterface interface {
	Init(actualTag string, tagsAvailable []string, value string)
	Evaluate() (matchWithRule bool, newTag string, err error)
	GetNewTag() string
}

func GetRule

func GetRule(name Name) (RuleInterface, error)

GetRule retrieves a RuleInterface based on the provided name. It takes a Name type as an argument and returns the corresponding RuleInterface from the rules map. If the name does not exist in the map, the behavior is dependent on the implementation of the rules map.

Parameters:

  • name: The name of the rule to retrieve.

Returns:

  • RuleInterface: The rule associated with the given name.

func GetRuleWithUntypedName

func GetRuleWithUntypedName(name string) (RuleInterface, error)

GetRuleWithUntypedName retrieves a RuleInterface based on the provided name. It takes a string as an argument and returns the corresponding RuleInterface from the rules map. If the name does not exist in the map, the behavior is dependent on the implementation of the rules map.

type Rules

type Rules map[Name]RuleInterface

Jump to

Keyboard shortcuts

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