-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
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
feat(ottl): Add a new ottl trim function that trims leading and trailing whitespace from a string #36400
base: main
Are you sure you want to change the base?
feat(ottl): Add a new ottl trim function that trims leading and trailing whitespace from a string #36400
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an entry to ottlfuncs/README
for this new converter
@rnishtala-sumo can you add to the description the issue this PR closes |
…ing whitespace from a string
c73ca02
to
b2c24fd
Compare
9c7f12c
to
22bb9aa
Compare
22bb9aa
to
d088773
Compare
|
||
```Trim(target, replacement)``` | ||
|
||
The `Trim` Converter removes the leading and trailing character (default: whitespace). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also add the default value description on the replacement
argument docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Take a look in this README how other Optional parameters are indicated (can use flatten as an example).
|
||
```Trim(target, replacement)``` | ||
|
||
The `Trim` Converter removes the leading and trailing character (default: whitespace). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Take a look in this README how other Optional parameters are indicated (can use flatten as an example).
if err != nil { | ||
return nil, err | ||
} | ||
if replacement.IsEmpty() || replacementString == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above line 34, lets to a check for if replacement == ""
and error if it is. Calling Trim(name, "")
implies a nop, but we'd be trimming " "
.
Description
A field test exists in an event, which contains the string " this is a test ".
I would like to be able to transform this using an ottl function trim, that I would define as trim(attribute["test"]), which would trim this down to "this is a test".
this is a test
Link to the issue - #34100