transformer

package
v0.75.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyInput is returned when we try to modify an empty value
	ErrEmptyInput = errors.New("validation error: transformer input is empty")
)

Functions

This section is empty.

Types

type FindSubMatch added in v0.21.0

type FindSubMatch struct {
	// Pattern defines regular expression to use for retrieving a submatch
	Pattern                string `yaml:",omitempty" jsonschema:"required"`
	DeprecatedCaptureIndex int    `yaml:"captureIndex,omitempty" jsonschema:"-"`
	// CaptureIndex defines which substring occurrence to retrieve. Note also that a value of `0` for `captureIndex` returns all submatches, and individual submatch indexes start at `1`.
	CaptureIndex int
}

FindSubMatch is a struct used to feed regexp.findSubMatch

func (*FindSubMatch) Apply added in v0.25.0

func (f *FindSubMatch) Apply(input string) (string, error)

func (*FindSubMatch) Validate added in v0.25.0

func (f *FindSubMatch) Validate() error

type Replacer

type Replacer struct {
	// From defines the source value which need to be replaced
	From string `yaml:",omitempty" jsonschema:"required"`
	// To defines the "to what" a "from" value needs to be replaced
	To string `yaml:",omitempty" jsonschema:"required"`
}

Replacer is struct used to feed strings.Replacer

func (Replacer) Unmarshal

func (r Replacer) Unmarshal() (result []string)

Unmarshal read a struct of Replacer then return a slice of string

type Replacers

type Replacers []Replacer

Replacers is an array of Replacer

func (Replacers) Unmarshal

func (replacers Replacers) Unmarshal() (result []string)

Unmarshal read a struct of Replacers then return a slice of string

type Transformer

type Transformer struct {
	// AddPrefix adds a prefix to the transformer input value
	AddPrefix           string `yaml:",omitempty"`
	DeprecatedAddPrefix string `yaml:"addPrefix,omitempty" jsonschema:"-"`
	// AddSuffix adds a suffix to the transformer input value
	AddSuffix           string `yaml:",omitempty"`
	DeprecatedAddSuffix string `yaml:"addSuffix,omitempty" jsonschema:"-"`
	// TrimPrefix removes a prefix to the transformer input value
	TrimPrefix           string `yaml:",omitempty"`
	DeprecatedTrimPrefix string `yaml:"trimPrefix,omitempty" jsonschema:"-"`
	// TrimSuffix removes the suffix from the transformer input value
	TrimSuffix           string `yaml:",omitempty"`
	DeprecatedTrimSuffix string `yaml:"trimSuffix,omitempty" jsonschema:"-"`
	// Replacers specifies a list of replacer instruction
	Replacers Replacers `yaml:",omitempty"`
	// Replacer specifies what value needs to be changed and how
	Replacer Replacer `yaml:",omitempty"`
	// Find searches for a specific value if it exists and return false if it doesn't
	Find string `yaml:",omitempty"`
	// Find searches for a specific value if it exists then return the value using regular expression
	FindSubMatch           FindSubMatch `yaml:",omitempty"`
	DeprecatedFindSubMatch interface{}  `yaml:"findSubMatch,omitempty" jsonschema:"-"`
	// SemvVerInc specifies a  comma separated list semantic versioning component that needs to be upgraded.
	SemVerInc           string `yaml:",omitempty"`
	DeprecatedSemVerInc string `yaml:"semverInc,omitempty" jsonschema:"-"`
}

Transformer holds a transformer rule

func (*Transformer) Apply

func (t *Transformer) Apply(input string) (output string, err error)

Apply applies a single transformation based on a key

func (*Transformer) Validate added in v0.25.0

func (t *Transformer) Validate() error

type Transformers

type Transformers []Transformer

Transformers defines a list of transformer applied in order

func (*Transformers) Apply

func (t *Transformers) Apply(input string) (string, error)

Apply applies a list of transformers

func (*Transformers) Validate added in v0.25.0

func (t *Transformers) Validate() error

Jump to

Keyboard shortcuts

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