We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An array of directive objects called modifications, which can be variants/components-overriden.
modifications
Available "directives":
$n
n
Specifying a regex instead of a string is done via the custom YAML tag !regex.
!regex
This requires switching to gopkg.in/yaml.v3 and use a special struct:
type stringOrRegexp struct { yaml.Node } func (sor stringOrRegexp) isRegexp() bool { return sor.Tag == "!regex" } func (sor stringOrRegexp) isString() bool { return sor.Tag == "!!str" } func (sor stringOrRegexp) regexp() (*regexp.Regexp, error) { return regexp.Compile(sor.Value) } func (sor stringOrRegexp) string() string { return fmt.Sprint(sor.Value) }
tested in Go playground, yaml won't unmarshal to stringOrRegexp even if it embeds yaml.Node, instead:
type stringOrRegexp = yaml.Node func isRegexp(sor stringOrRegexp) bool { return sor.Tag == "!regex" } func isString(sor stringOrRegexp) bool { return sor.Tag == "!!str" }
And in the manifest:
type Modification struct { In string Before stringOrRegexp After stringOrRegexp Replace stringOrRegexp With string Append string Preprend string } type Manifest struct { ... Modifications []Modification ... } func (m Modification) searchAndReplace() { var searchPattern *regexp.Regexp if isRegexp(m.Replace) { searchPattern, err := regexp.Compile(m.Replace.Value) } else if isString(m.Replace) { searchPattern, err := regexp.Compile(regexp.Escape(m.Replace.Value)) # ^1 } else { return // no replacement to do, `replace` field not mentionned } if err != nil { ... } ... }
The text was updated successfully, but these errors were encountered:
prepend
append
with
ewen-lbh
No branches or pull requests
An array of directive objects called
modifications
, which can be variants/components-overriden.Available "directives":
$n
will refer to then
-th capture groupSpecifying a regex instead of a string is done via the custom YAML tag
!regex
.This requires switching to gopkg.in/yaml.v3
and use a special struct:tested in Go playground, yaml won't unmarshal to stringOrRegexp even if it embeds yaml.Node, instead:
And in the manifest:
The text was updated successfully, but these errors were encountered: