Skip to content
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

Support for required function parameters #2041

Open
morgante opened this issue May 18, 2021 · 5 comments
Open

Support for required function parameters #2041

morgante opened this issue May 18, 2021 · 5 comments
Labels
area/hydrate customer deep engagement enhancement New feature or request p1 triaged Issue has been triaged by adding an `area/` label ux impact

Comments

@morgante
Copy link
Contributor

I would like a way to mark a function parameter as required in a Kptfile, such that the package consumer must provide their own value for it (no default is available).

Based on setting a parameter as required, I'd like the following features to be possible:

  • Machine-parseable, so that we can auto-generate documentation
  • Listed as a required customization in any info CLI commands
  • If I attempt to run other kpt commands (ex. kpt live apply) without filling in a required customization it should fail fast

Describe alternatives you've considered

These can be documented separately but that is inconsistent and error-prone.

Additional context

kpt 0.3x supported required setters.

@morgante morgante added the enhancement New feature or request label May 18, 2021
@mikebz mikebz added this to To do in kpt kanban board via automation May 18, 2021
@mikebz mikebz added ux impact area/hydrate triaged Issue has been triaged by adding an `area/` label labels May 18, 2021
@mikebz mikebz added this to the v1.0 m3 milestone May 18, 2021
@mikebz mikebz added the customer deep engagement label May 18, 2021
@mikebz
Copy link
Contributor

mikebz commented May 18, 2021

@phanimarupaka @frankfarzan @droot - heads up, this needs design work. Originally slotted to post v1 in a conversation with @bgrant0607 but seems like a potential usability speedbump for LZ customers.

@morgante
Copy link
Contributor Author

@mikebz We don't necessarily need to block the v1 launch on it, but it's definitely a fast-follow item.

@frankfarzan frankfarzan modified the milestones: v1.0 m3, v1.1 May 19, 2021
@frankfarzan frankfarzan removed their assignment Jun 22, 2021
@bgrant0607
Copy link
Contributor

bgrant0607 commented Jun 24, 2021

Function parameter descriptions and declarative validation are needed.

For required vs optional, I like delegating that to the Kptfile rather than to the function metadata. The user could toggle the property as necessary.

Another way we could possibly treat it is as a priority spectrum: P0 must be set, P1 would be recommended, P2 would be optional, P3 would be unlikely to be changed. Or we could use words for that: an enum rather than a bool: required, recommended, optional, advanced. Or something like that. To facilitate progressive disclosure.

@phanimarupaka
Copy link
Contributor

Function parameter descriptions and declarative validation are needed.

This is something in our radar already. We are trying to figure out the right UX for package publishers to provide the validation rules for function parameters without loosing the simplicity of model. These rules can also be consumed by Cloud Code to provide authoring assist to users.

For required vs optional, I like delegating that to the Kptfile rather than to the function metadata. The user could toggle the property as necessary.

There are 2 layers here.

  1. Function author sets few obvious rules on function parameters. For e.g. set-namespace function needs namespace parameter to be passed. Package publisher need not worry about that.
  2. Package publisher can set additional rules. For e.g. The namespace parameter should have my-org prefix and should be of maximum length of 10 chars.

Another way we could possibly treat it is as a priority spectrum: P0 must be set, P1 would be recommended, P2 would be optional, P3 would be unlikely to be changed. Or we could use words for that: an enum rather than a bool: required, recommended, optional, advanced. Or something like that. To facilitate progressive disclosure.

@bgrant0607
Copy link
Contributor

Kustomize uses KRM types for function inputs:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2906-kustomize-function-catalog
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2299-kustomize-plugin-composition

That provides a means for defining the input schemas -- CRDs.

If we were going to go that route, we'd want a kubebuilder-like mechanism in the function SDKs to generate the CRDs:
https://book.kubebuilder.io/cronjob-tutorial/new-api.html

We'd also want extensible kubegen-like tooling to generate the 5+ lines of boilerplate for each individual function input object.

The catalog mechanism could also automatically map types to functions without explicitly specifying the functions in every Kptfile.

@justinsb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hydrate customer deep engagement enhancement New feature or request p1 triaged Issue has been triaged by adding an `area/` label ux impact
Projects
None yet
Development

No branches or pull requests

6 participants