-
Notifications
You must be signed in to change notification settings - Fork 230
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
New Starlark fn does not support custom parameters nor imperative run #1889
Comments
@mengqiy heads up |
@yhrn Thanks a lot for your feedbacks!
This is planed to be solved in #1560.
To support it, we will need to support ConfigMap as fn config. We will share the design with you when we have something. |
This is becoming a blocker for Spotify: #1834 (comment)
Re. supporting imperative run, @frankfarzan I remember you have some thoughts. Can you please elaborate? |
@yhrn Can you please explain a bit why imperative run is important to you?
Is that reasonable to you? |
# Expand StarlarkRun resource
$ kpt fn eval --image gcr.io/kpt-fn/generate-starlark-run --mount ...
# Run starklark function with expanded StarlarkRun (Or alternatively run starlark using eval)
$ kpt fn render You only need to run the generate function when there's a change in the starlark script. Alternatively, there can be a generic function that can expand KRM fields pointing to file contents # Expand KRM fields referencing (via a setter-like comment) a file.
# This can only be run imperatively.
$ kpt fn eval --image gcr.io/kpt-fn/file-substitution --mount ...
# Run starlark function with expanded StarlarkRun
$ kpt fn render This option is more generally applicable to executive configuration pattern: https://kpt.dev/book/05-developing-functions/04-executable-configuration Both of these can be done without changing kpt CLI, as they're purely optional porcelain. If the use case is to run Starlark with |
Imperative run is important to us because we often do out-of-place rendering. Also, having a raw *.star file significantly improves the developer experience. I suppose the wrapper function idea works but I don't think it is very intuitive and it would also need to support passing parameters to the actual function. Compare the suggested workaround to:
|
I have a proposal here: functionConfigAdd a new field called An example
Developer ExperienceFirst, user needs to install the $ go get github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/starlark@<the-desired-version> Users are going to develop and iterate on this starlark script using the following command. $ kpt fn eval --exec "starlark path/to/sourcefile.star" -- param1=foo param2=bar Running the above command is equivalent to the following: $ kpt fn eval --image gcr.io/kpt-fn/starlark:v0.1 --fn-config starlark-fn-config.yaml where starlark-fn-config.yaml is: apiVersion: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
name: starlark-fn-config
parameters:
param1: foo
param2: bar
source: |
# content of sourcefile.star
starlark source comes here ... To generate a StarlarkRun resource with source and parameters.
Option 2: Use function Implementation DetailsChanges to
|
@yhrn WDYT? |
Seems like the current implementation as well as the proposed enhancements/developer workflow are still comprised of key/value string pairs. Would it be a bad pattern if |
It sounds like you are suggesting something like this:
@droot @frankfarzan Thoughts? |
Regarding the proposal I think that it addresses the most important blocker from my PoW by supporting simple parameters. That said also think that this is still a significant regression compared to the built in Starlark runtime:
All in all, providing Starlark as a fn rather than a supported runtime just seems to give a lower fidelity experience. |
We can support kpt fn eval --image starlark:v0.1 -- source=$(cat main.star) key1=val1 key2=val2 This should provide a simple enough developer experience. A developer can keeper iterate on it until the starlark script is ready. After that the user may want to run the script with
We can automate it a bit.
We can alternatively make starlark smarter. The starlark function will look the starlark script file in a specific location. If found, the starlark function will execute that script. A user can choose to mount the starlark file in the starlark container.
Current declarative UX:
We can automate it a bit:
|
Being able to do I guess the concern not addressed is that there is no way to pass a complex structure as configuration to the Starlark code. It means that you can no longer treat is as (mostly) an implementation detail if you choose to write your fn using Starlark or Go/Typescript, but maybe that is not a too common use case. |
It's possible to support complex structure (which can be present by yaml) in |
Yes, that makes sense and I didn't mean that it should be supported for the If it's supported for the |
Created this issue for the |
@mengqiy shouldn't there be a release of the starlark kpt fn too before this is fully done? Right now the new functionality can only be accessed via the |
With the code in a ConfigMap, is it possible to inline the Starlark code and parameters into the Kptfile? |
@yhrn In case you missed it, the starlark:v0.2.0 function has been released. |
@bgrant0607 It's possible. But I guess it's not recommended unless the starlark script is very short. Otherwise, it may make the Kptfile a little verbose. |
Apologies if this is premature feedback - I realize that this is yet to be released officially. Feel free to close if this is already planned for.
I tried out the new Starlark fn and it's pretty limited compared to the current built in alpha functionality:
source
What I would like is to be able to do something like:
Less important, but it would also be nice to be able to use a custom config structure that gets passed into the starlark function (in
ctx.resource_list["functionConfig"]
) like you can today with the Starlark runtimeThe text was updated successfully, but these errors were encountered: