-
Notifications
You must be signed in to change notification settings - Fork 409
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
Feature Request: add more template functions #702
Comments
The multiple variable names for interfaces was just bad planning on my part, I don't have an excuse for that. I'm surprised you think the list of function is "small," I thought we added quite a lot 😅 One of the things we need to do is fix the argument ordering because currently pipelining is sort of broken for the functions we currently have. I think we need a feature flag that fixes the argument ordering, and then add any additional functions to the set of functions enabled with that flag (this way, people are encouraged to use the new function set). I'm not really sure if we need this mega set of functions that sprig provides. It's certainly enticing but I would like a better argument for attaching ourselves to that project rather than just "more functions = good". The number of variables that support templating in this project is pretty low, and mostly involves path/name manipulation. I think sprig is more useful for large HTML templates (or any text document really). Consequently, I don't see a good argument for adding it. It's a huge dependency for not that much value, IMO. |
I agree that for mockery purposes there is no need for all the functions. What I actually wanted is String functions, because I have a problem converting |
We may select a smaller set of functions or implement them in this codebase. Could you please tell us what was your exact problem? What's your package name? |
So basically my plan was to create a general mockname for all structs that I generate with pattern like this:
For So I did just:
but I have more than 10+ interfaces with such a config. Here is the list of functions that I would like to have: |
I am totally okay with adding those list of functions you mentioned, I think those are definitely useful for folks. Do you want to add a PR? I could probably do it myself but it will take me maybe a couple of weeks. |
Yes, I can do it myself, not a problem. |
Description
Right now the list of possible template functions is pretty small. I suggest to use the same set of functions as
helm
does.Masterminds/sprig provides general
FuncMap
that can be used in addition to existing functions.This approach will also allow to avoid multiple variables for
InterfaceName
(InterfaceNameCamel / InterfaceNameLowerCamel / InterfaceNameSnake / InterfaceNameLower). It should be done as:{{ .InterfaceName | upper }}
or{{ .InterfaceName | snakecase }}
Mockery Version
v2.33.2
Golang Version
v1.20
Installation Method
The text was updated successfully, but these errors were encountered: