Golang user-defined functions #2498
-
Besides the builtin functions available from the cuelang package, is it possible to call Golang functions from user-defined or other standard library packages. Specifically I would like to use |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
This sort of extensibility will be covered by the WebAssembly (Wasm) work that we are doing: #2463. Such Wasm modules will then be distributed via modules (#2330). In this way, people will not be limited by the standard library of builtins that we (currently) offer. That said, there are often strong arguments for making something part of the standard library. I would suggest that (Incidentally, we also somewhat envisage a Go-like cc @4ad for more information on the Wasm side of things. |
Beta Was this translation helpful? Give feedback.
-
Thank you. I've opened a feature request here #2499 |
Beta Was this translation helpful? Give feedback.
-
Re-opening this discussion given #2498 (reply in thread) (because I keep trying to find this discussion and failing because it's closed!) |
Beta Was this translation helpful? Give feedback.
-
Tangentially related in that this should never be a native builtin - I have really, really wanted to match Kubernetes labels against a label selector (using the labels package in k8s). This would really simplify our cue-crossplane compositions by being able to conditionally set attributes based on object labels. Right now, we have to do some preprocessing elsewhere and hand the results to cue. |
Beta Was this translation helpful? Give feedback.
-
Hello, Are you working to enable the ability to use, user defined functions ? I see an update in #2498 (reply in thread), but not sure if you are referring to adding I am working on a DSL based on CUE language. A connection to a SFTP server is defined as:
so I can declare a connection as:
This works, but I don't want sensitive details go into the version control. So I would like to read
With that I updated
and I can declare a connection without sensitive details:
This works, but I am thinking if I can import a user defined library this can be more readable:
Thanks for your work in CUE language. |
Beta Was this translation helpful? Give feedback.
This sort of extensibility will be covered by the WebAssembly (Wasm) work that we are doing: #2463. Such Wasm modules will then be distributed via modules (#2330). In this way, people will not be limited by the standard library of builtins that we (currently) offer.
That said, there are often strong arguments for making something part of the standard library. I would suggest that
mail.ParseAddress
comes pretty close to passing an as-yet-undefined threshold for inclusion. Please can you raise a feature request to that end if you would like this added? It feels ok to me, but a feature request will help to confirm.(Incidentally, we also somewhat envisage a Go-like
cuelang.org/x/...
namespac…