-
Notifications
You must be signed in to change notification settings - Fork 221
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
[TEP-0075, 0076] Make array and object support implementable 👷♀️ #661
[TEP-0075, 0076] Make array and object support implementable 👷♀️ #661
Conversation
Update the TEPs about array and object support (TEP-0075 and TEP-0076) to be implementable. Also addressing feedback from @afrittoli in tektoncd#479
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exciting! 🎉
/assign @jerop
/assign @vdemeester
/assign wlynch |
Thanks for the updates!
If we provided a syntax to check if a value is defined, it could be ok. Otherwise I don't see what purpose an optional field in an object parameter would serve, they'd be unusable since referring to an optional parameter might trigger a failure at any time and it would not be possible to build conditional logic anywhere. To go back the my example in the previous PR:
The check above would not be possible, so the Default values do not solve this in case of objects, because defaults for objects - if I understood correctly - will only be at object level, so to make use of
I'll try to produce an example, but I agree this is not blocking for this PR / initial implementation.
|
Thanks for the example @afrittoli ! I agree that it feels strange for a field to be optional, however for any attempts to use that optional field to fail. It feels like all of the options we have for this (https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md#required-vs-optional-keys) are not great in their own way. I don't think that list includes an option where we have "zero value" for fields that aren't specified, which I think is what you were suggesting (e.g. "" for a string field that is missing) - we should at least list that as an alternative, and maybe that's the best option but I think that pulls in TEP-0048 as well i.e. do we always do this for missing values and how do you tell the difference between "" b/c something wasn't provided and "" when explicitly provided...
Maybe a good reason to actually support merging the default with the provided object after all? Another idea: supporting a syntax that lets you specify a default when you use a value, e.g.: params:
- name: foo
type: object
properties:
bar: {}
needed: {}
required: ["needed"]
steps:
- name: first-step
image: alpine
env:
- name: FOO_BAR
value: $(params.foo.bar:"some-default") Anyway none of the options really seem great 😅 was discussing with @wlynch a bit today and he might have some ideas |
I agree that an optional field shouldn't fail the run. I'm also voting that if the optional field is not provided, "zero" values should be inserted. I'm not sure if we have a use case for that we want to distinguish the difference between something wasn't provided and when that's explicitly provided, as optional field should be optional that this detail may not be necessary. Currently I can't think of such case in terms of optional field, but I could be missing some edge cases XD
I really think the feature to letting users specifying a default value for a non object type of field in object field access will be beneficial, and providing the defaults at variable replacement seems more intuitive, and code doesn't have to check back the schema definition of the object. We could first having support for the zero values, and plan for supporting this default value syntax. Regarding to default values for object types, we do have the option for merging the default with the provided object, but do we really want to go down this route, since objects can be have multiple layers of nested objects? And is that a complicated feature that's useful? We also have to consider the required fields within an optional field that's a object... |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jerop, vdemeester, wlynch The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summarizing from last week's API working group - it sounded like we were leaning towards making all fields required to start, and just documenting it as an unsupported field? Another question we should figure out (though it doesn't really change the core of this proposal so isn't blocking) is whether we want to use vanilla json schema or OpenAPI spec (which is mostly similar, but diverges from the original json schema spec in a few aspects). |
Realized I missed the API WG...
|
/test pull-community-teps-lint |
For this specifically it was initially brought up by me - I think that's something we might consider as a follow-up feature, but I would not include it necessarily in the initial design |
+1
What would be the advantage of OpenAPI vs jsonschema? |
re. json schema vs OpenAPI - there's a quick blurb about this in the proposal (https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md#why-json-schema) - my understanding is that the JSON schema features we're proposing are compatible with OpenAPI schema so we could adopt it later if there are compelling features we need |
After recent discussions in API working group, landing on implying the required field by default and not supporting users explicitly specifying required fields - seems to be the best balance of the functionality we want and setting us up to be able to change the behavior later if needed. Added another alternative for how to handle required vs optional: if we provided a default value when optional fields are missing Added future work where we could support "no schema" i.e. objects that could have any keys and declare none.
2f74332
to
080db4a
Compare
@ywluogg :
Yes - at least initially. We can always add support for optional fields later.
Yes 🙏 The most recent commit should provide more detail around the 'no schema' feature and around the optional vs required fields 080db4a |
I've update this PR with the changes we discussed in the last WG - and it looks like we've got approval from all the approvers :D |
/kind tep (to make sure we merge it at API WG today) |
Approved at API WG /lgtm |
Update the TEPs about array and object support (TEP-0075 and TEP-0076)
to be implementable.
Also addressing feedback from @afrittoli in #479
Outstanding items:
cc @wlynch