-
Notifications
You must be signed in to change notification settings - Fork 528
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
fix(30216): Add more docs for must version of functions #1698
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Derek Brown <[email protected]>
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 am not a maintainer, but there are some changes that need to happen here, thanks!
@@ -857,18 +857,38 @@ Helm includes the following regular expression functions: [regexFind | |||
(mustRegexReplaceAllLiteral)](#regexreplaceallliteral-mustregexreplaceallliteral), | |||
[regexSplit (mustRegexSplit)](#regexsplit-mustregexsplit). | |||
|
|||
### regexMatch, mustRegexMatch | |||
### regexMatch |
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.
There are links above and this change breaks that. I don't think you should change the headers or add the ### mustRegexMatch
header here.
`regexMatch` will ignore regex compilation errors, and simply return `false` ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L7)) | ||
|
||
``` | ||
{{- if regexMatch "[" "abc" -}} | ||
valid: true | ||
{{- end -}} | ||
``` | ||
The above produces nothing. | ||
|
||
### mustRegexMatch | ||
|
||
Similar to `regexMatch`, but will return an error to the templating engine if the regex fails to compile: |
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.
`regexMatch` will ignore regex compilation errors, and simply return `false` ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L7)) | |
``` | |
{{- if regexMatch "[" "abc" -}} | |
valid: true | |
{{- end -}} | |
``` | |
The above produces nothing. | |
### mustRegexMatch | |
Similar to `regexMatch`, but will return an error to the templating engine if the regex fails to compile: | |
In the event of regex compilation errors, `regexMatch` will simply return `false`. | |
Use `mustRegexMatch` to fail in the event of regex compilation errors. |
@@ -885,7 +905,7 @@ The above produces `[2 4 6 8]` | |||
`regexFindAll` panics if there is a problem and `mustRegexFindAll` returns an | |||
error to the template engine if there is a problem. | |||
|
|||
### regexFind, mustRegexFind | |||
### regexFind |
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.
### regexFind | |
### regexFind, mustRegexFind |
`regexFind` will result in a panic if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L30)), whereas | ||
`mustRegexFind` will return an error to the templating engine if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L34)). |
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 think these references are going to be brittle
`regexFind` will result in a panic if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L30)), whereas | |
`mustRegexFind` will return an error to the templating engine if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L34)). | |
The `regexFind` function will result in a panic if the regex fails to compile, whereas | |
`mustRegexFind` will return an error to the templating engine if the regex fails to compile. |
`regexFind` will result in a panic if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L30)), whereas | ||
`mustRegexFind` will return an error to the templating engine if the regex fails to compile ([ref](https://github.com/Masterminds/sprig/blob/master/regex.go#L34)). | ||
|
||
Note that neither function will panic/return an error if the input string does not match the regex. Both functions return an empty string in this case: |
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.
This project doesn't strictly use semantic line breaks, but I think it helps.
Note that neither function will panic/return an error if the input string does not match the regex. Both functions return an empty string in this case: | |
Note that neither function will panic/return an error if the input string does not match the regex. | |
Both functions return an empty string in this case: |
What does this PR do?