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
Is there an equivalent to sprig's set
?
#1783
Comments
There is not currently an equivalent. I considered asking a It's not too complex, and I'm not opposed to it. One factor with sprig's implementation is that it modifies the input; I think I would rather leave the input unmodified, and instead return a copy, so that further uses of the input map are left intact (you can always re-assign the input variable if you do want to overwrite it) FWIW, the $ gomplate -i '{{ $m := dict "foo" "bar" }}{{ $m = jq `. += { baz: "qux" }` $m }}m is {{ $m }}'
m is map[baz:qux foo:bar] LMK what you think! |
Oh! I think I remember now why I didn't add a So your example can be done like this:
A func (f *CollFuncs) Set(in map[string]interface{}, key string, val interface{}) (map[string]interface{}, error) {
return f.Merge(in, map[string]interface{}{key: val})
} |
@hairyhenderson my problem with the merge approach is actually the fact that it copies the map, which results in massive inefficiency when doing things like iteratively building up a map in a loop (you don't want to know the horrors of what I am doing with gomplate). |
While we are here, if we are allowing maps to be mutable, I would appreciate a Here is sprigs implementation for |
And one more thing! A true Here is sprigs implementation of |
Ah - thanks @thesuperzapper. Updating does indeed make sense for your use-case (if I didn't want to know the horrors, why'd you link it? I couldn't resist looking! 🤣) Is I'll see about getting these all added before |
@hairyhenderson If we are implementing In any case, I'm going to be releasing the first version of deployKF today after a very long time (I almost don't want to think) and I would like to thank you for that great foundation that gomplate provides (Even if I have had to fork it to change a few things). If you ever need a machine learning platform on Kubernetes, you know what to use! |
@hairyhenderson was there any movement on getting |
not yet - I've made some progress on v4 in general (there's a prerelease now!), but this is still outstanding |
I am needing to update the contents of an existing
dict
, but I see thatset
does not exist.In sprig, the following can be used to update
$myDict
:Is there an equivalent that I am missing in gomplate?
The text was updated successfully, but these errors were encountered: