Skip to content

Commit

Permalink
[chore] [pkg/stanza] move config validation (#38475)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny authored Mar 8, 2025
1 parent c2f9401 commit 0834a26
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/stanza/operator/transformer/regexreplace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ type Config struct {
}

func (c *Config) getRegexp() (*regexp.Regexp, error) {
if (c.RegexName == "") == (c.Regex == "") {
return nil, fmt.Errorf("either regex or regex_name must be set")
}

switch c.RegexName {
case "ansi_control_sequences":
return ansiCsiEscapeRegex, nil
Expand All @@ -66,6 +62,10 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error
return nil, err
}

if (c.RegexName == "") == (c.Regex == "") {
return nil, fmt.Errorf("either regex or regex_name must be set")
}

regexp, err := c.getRegexp()
if err != nil {
return nil, err
Expand Down

0 comments on commit 0834a26

Please sign in to comment.