-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: More flexible ways to provide values for object param keys #5427
TEP-0075: More flexible ways to provide values for object param keys #5427
Conversation
/kind feature |
cc @lbernick @wlynch @chitrangpatel @ywluogg @Yongxuanzhang |
The following is the coverage report on the affected files.
|
/test check-pr-has-kind-label |
@afrittoli: The specified target(s) for
The following commands are available to trigger optional jobs:
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Thank you @chuangw6 - could you please provide release notes for this feature, and check the submitter checklist? |
189bb11
to
d850ab8
Compare
Added! Thanks @afrittoli ! |
The following is the coverage report on the affected files.
|
/retest |
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.
I think this is actually two separate changes:
- if default is provided for all keys, the values from the run will be merged with the defaults
- the default does not have to be provided for all keys
Is it clear that we want both of these features?
We might also want to update tep 75 before merging this
@@ -686,27 +686,6 @@ func TestTaskSpecValidateError(t *testing.T) { | |||
Message: fmt.Sprintf("The value type specified for these keys %v is invalid", []string{"key1"}), | |||
Paths: []string{"params.task.properties"}, | |||
}, | |||
}, { | |||
name: "keys defined in properties are missed in default", |
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.
let's keep this test case around but just have it result in a successful validation.
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.
Sounds great! Done. Thanks @lbernick
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.
I think you might not have pushed these changes?
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.
It's under the valid test cases called valid params type explicit
and the param name is myobjWithDefaultPartialKeys
.
|
d850ab8
to
3b7ba03
Compare
The following is the coverage report on the affected files.
|
Not only for default but also the value provided on the taskrun level. Both of them do not have to be provided for all keys. (Prior, the validation enforces that they have to provide values for all keys if they provide value for the object param.)
This is true. But I'd think this as the implication of that both default and taskrun do not need to provide value for all keys of an object param. Currently tep75 says "If a value is provided for the param, the default will not be used (i.e. there will be no behavior to merge the default with the provided value, if for example the provided value specified some fields but not others).". If we do not have the merge behaviour, what will happen is that the keys missed at taskrun value will have empty value even though the For example, and object param named
IMHO, the 2nd case might make more sense, but I am open to the discussion here. And I agree that we need to update the tep before merging this. |
Thanks for the response @chuangw6! Let's say we start with not requiring the default to specify all keys. In order for this to be useful, we will either need the merge behavior (so that unspecified defaults can be provided at runtime), or we will need to allow object keys to be optional. Probably both! We could start with just the merge behavior, but still require the default to specify all keys. There's definitely some examples where this could be useful, e.g. a git object param with a default url like the example you have in this PR. In the example you provided, without merging behavior, one of the keys would not be set, and the taskrun would fail because we don't support optional keys, correct? Merging behavior would be backwards incompatible in the sense that this would no longer fail, but because we don't support optional keys we don't need to provide a mechanism to "unset" a key at runtime. I think we might want to start with just the merge behavior to avoid getting into optional vs required keys, WDYT? |
Starting with merge behaviour to avoid optional v.s. required keys SGTM!
But it seems to me that default does not have to specify all keys, which is not related to optional/required keys. Currently, the tep proposed that all keys specified in properties are required. Therefore, in the following example, an error will be thrown because we find out that neither taskrun or default provides a value for the required key apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: object-param-test-
spec:
params:
- name: gitrepo
value:
url: "xyz.com"
taskSpec:
params:
- name: gitrepo
properties:
url: {}
commit: {}
default:
url: "default.com" If the above example provides the value (i.e. "sha123") for key |
ok -- I'm convinced that this doesn't require optional keys and isn't backwards incompatible (because we were previously requiring the taskrun to provide a value for all keys if it overrode the default) |
@@ -686,27 +686,6 @@ func TestTaskSpecValidateError(t *testing.T) { | |||
Message: fmt.Sprintf("The value type specified for these keys %v is invalid", []string{"key1"}), | |||
Paths: []string{"params.task.properties"}, | |||
}, | |||
}, { | |||
name: "keys defined in properties are missed in default", |
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.
I think you might not have pushed these changes?
Correct. Now taskrun can still provide a value for all keys, but they don't have to as long as default provides a value for the keys that are missed at tasrkun. |
3b7ba03
to
868bd21
Compare
The following is the coverage report on the affected files.
|
868bd21
to
e83ade5
Compare
Related to tektoncd#5270. Prior to this change, if users want to provide default value for an object param, they have to provide values for ALL keys, but can't provide values for a subset of required keys that are declared in `properties` section. Same restriction applies to the `value` provided from run level. In this PR, we relax the validation for object param keys to allow users to provide values for an object param in a more flexible way i.e. a subset of keys are provided in the spec's default, and the rest of the keys are provided in run level's value. Signed-off-by: Chuang Wang <[email protected]>
e83ade5
to
8e17261
Compare
The following is the coverage report on the affected files.
|
related to tektoncd/pipeline#5427. Prior to this update, merge behaviour was not allowed between `default` and run level value for object keys. In that proposal and the implementation pr, we allow the merge behaviour to happen to give users more flexible ways to provide values for object param as long as all keys are provided with a value at runtime (combination of the values provided from default and run level value). Signed-off-by: Chuang Wang <[email protected]>
related to tektoncd/pipeline#5427. Prior to this update, merge behaviour was not allowed between `default` and run level value for object keys. In that proposal and the implementation pr, we allow the merge behaviour to happen to give users more flexible ways to provide values for object param as long as all keys are provided with a value at runtime (combination of the values provided from default and run level value). Signed-off-by: Chuang Wang <[email protected]>
I also updated the tep tektoncd/community#817. Please take a look @lbernick. Thanks! |
related to tektoncd/pipeline#5427. Prior to this update, merge behaviour was not allowed between `default` and run level value for object keys. In that proposal and the implementation pr, we allow the merge behaviour to happen to give users more flexible ways to provide values for object param as long as all keys are provided with a value at runtime (combination of the values provided from default and run level value). Signed-off-by: Chuang Wang <[email protected]>
related to tektoncd/pipeline#5427. Prior to this update, merge behaviour was not allowed between `default` and run level value for object keys. In that proposal and the implementation pr, we allow the merge behaviour to happen to give users more flexible ways to provide values for object param as long as all keys are provided with a value at runtime (combination of the values provided from default and run level value). Signed-off-by: Chuang Wang <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lbernick, vdemeester 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 |
} | ||
|
||
// ValidateObjectKeys validates if object keys defined in properties are all provided in its value provider iff the provider is not nil. | ||
func ValidateObjectKeys(properties map[string]PropertySpec, propertiesProvider *ParamValue) (errs *apis.FieldError) { |
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.
Ah can you leave this function as is? I'm planning to use it in Chains. I think initially you are making this function public because I need to do keys comparisons in Chains, is it?
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.
Oh NVM because you are not using this function anymore in Pipeline, I will create this one in Chains then. Please ignore the previous commnent
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.
/lgtm
/test pull-tekton-pipeline-integration-tests |
Tep 75 was updated to reflect the change as well. tektoncd/community#817 |
related to tektoncd/pipeline#5427. Prior to this update, merge behaviour was not allowed between `default` and run level value for object keys. In that proposal and the implementation pr, we allow the merge behaviour to happen to give users more flexible ways to provide values for object param as long as all keys are provided with a value at runtime (combination of the values provided from default and run level value). Signed-off-by: Chuang Wang <[email protected]>
Changes
Closes #5270.
Prior to this change, if users want to provide default value for an
object param, they have to provide values for ALL keys, but can't provide
values for a subset of required keys that are declared in
properties
section. Same restriction applies to the
value
provided from run level.In this PR, we relax the validation for object param keys to allow users
to provide values for an object param in a more flexible way i.e. a subset
of keys are provided in the spec's default, and the rest of the keys are
provided in run level's value.
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes