external-dns
external-dns copied to clipboard
feat: additional template functions
Description
Adds a few useful text/template functions:
- replaceAll:
strings.replaceAll - isIPv6: exposes an existing function that returns a bool to let you know if a string is an IPv6 address
- isIPv4: a new function that returns a bool to let you know if a string is an IPv4 address
N/A
Checklist
- [x] Unit tests updated
- [x] End user documentation updated
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: matkam / name: Mathew Kamkar (6b0d792a19bc0934a83cd9367a344e7c9aabdc64, a5f3a17603fa4caba6da44c5ed9144181f533556, 68be9bda50747f39ea4052bd5ec264b5de5164b7, b0f3beb89992bf0d7bc127ad87dad912453eb92d, b610c94a5c0925ef49c37370e0faa819a7f4850e, 42f79f82501bd40a424db1550fd1aa7a491cbbdd, 88bfa6083f86225d6991adeacff1f5bf6ad9bc8f, 267cb1f1b612be2a641d915ab675c0f1e588ce78)
Welcome @matkam!
It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
Hi @matkam. Thanks for your PR.
I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Please submit a CLA per the instructions above.
Please submit a CLA per the instructions above.
Yes 👍 I'm just waiting on my employer to click the button.
@johngmyers we are good to go here 👍
Sprig has replace, which is similar. Perhaps we should follow their syntax?
/ok-to-test
Sprig has
replace, which is similar. Perhaps we should follow their syntax?
does replace work differently? I could also add strings.replace to the FuncMap.
I believe replace has the arguments in a different order. See the documentation in https://masterminds.github.io/sprig/strings.html
I believe
replacehas the arguments in a different order. See the documentation in https://masterminds.github.io/sprig/strings.html
sprig looks like a nice package. how about just importing it and using hermeticTxtFuncMap like this:
func parseTemplate(fqdnTemplate string) (tmpl *template.Template, err error) {
if fqdnTemplate == "" {
return nil, nil
}
funcs := sprig.HermeticTxtFuncMap()
funcs["isIPv6"] = isIPv6String
funcs["isIPv4"] = isIPv4String
return template.New("endpoint").Funcs(funcs).Parse(fqdnTemplate)
}
@johngmyers let me know what you think. I've updated the template functions to include Sprig's hermetic text functions, and fixed the isIPv4String function so that it only returns true for valid IPv4 strings.
@matkam Wdyt about adding isIPv4 and isIPv6 directly into slim-sprig ?
@mloiseleur https://github.com/go-task/slim-sprig/pull/16
/hold for https://github.com/go-task/slim-sprig/pull/16
@matkam: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| pull-external-dns-lint | c16c17556b32a6fe4d85960df82eeca6257af939 | link | true | /test pull-external-dns-lint |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.
@matkam Since slim-sprig maintainer does not review your PR, I think we can merge this one. Do you think you can rebase this PR ? And precise in documentation those additional functions of isIPv4 and isIPv6 ?
@mloiseleur done!
/lgtm
@mloiseleur whats the next step required to get this merged?
A review from @szuecs or @Raffo They will review this PR when they have time.
/unhold
/retitle feat: additional template functions
Hello, I would like to see this merged and released. What needs to be done?
New changes are detected. LGTM label has been removed.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please ask for approval from mloiseleur. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment