-
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
Task, ClusterTask and Pipeline auto-conversion from v1alpha1 to v1alpha2 🎋 #2002
Task, ClusterTask and Pipeline auto-conversion from v1alpha1 to v1alpha2 🎋 #2002
Conversation
switch sink := obj.(type) { | ||
case *v1alpha2.Pipeline: | ||
sink.ObjectMeta = source.ObjectMeta | ||
return nil // source.Spec.ConvertUp(ctx, &sink.Spec) |
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.
This is a placeholder 👼 I needed to define at least 2 Convertible types to some tests 😝
@@ -46,6 +45,8 @@ func (t *Task) Copy() TaskInterface { | |||
|
|||
// TaskSpec defines the desired state of Task. | |||
type TaskSpec struct { | |||
v1alpha2.TaskSpec `json:",inline"` |
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.
This is not required per-se, it just simplify the conversion using embedded struct and it doesn't change on the api side (except user of the go library)
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.
If you look at Pipeline
, it is not using embedding as we can't really do that (same task
field targeting different type)
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.
aha, so this is how TaskSpec.ConvertDown is able to copy into the v1alpha1.Params and Resources fields?
👍
15a7bd5
to
f71d174
Compare
The following is the coverage report on pkg/.
|
f71d174
to
eb8a6f2
Compare
The following is the coverage report on pkg/.
|
eb8a6f2
to
5371f99
Compare
The following is the coverage report on pkg/.
|
90e16b2
to
71fc0d5
Compare
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
sink.Resources = &v1alpha2.TaskResources{} | ||
} | ||
if len(source.Inputs.Resources) > 0 && source.Resources != nil && len(source.Resources.Inputs) > 0 { | ||
// This shouldn't happen as it shouldn't pass validation but just in case |
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.
👍
// This shouldn't happen as it shouldn't pass validation but just in case | ||
return apis.ErrMultipleOneOf("inputs.resources", "resources.inputs") | ||
} | ||
sink.Resources.Inputs = make([]v1alpha2.TaskResource, len(source.Inputs.Resources)) |
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.
🎉
@@ -46,6 +45,8 @@ func (t *Task) Copy() TaskInterface { | |||
|
|||
// TaskSpec defines the desired state of Task. | |||
type TaskSpec struct { | |||
v1alpha2.TaskSpec `json:",inline"` |
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.
aha, so this is how TaskSpec.ConvertDown is able to copy into the v1alpha1.Params and Resources fields?
👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg 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 |
I don't totally understand the need for v1alpha1 ConvertDown funcs. What is their use? |
I did write about this in the initial pull request #1529 :
The main reason to |
71fc0d5
to
dbe103c
Compare
The following is the coverage report on pkg/.
|
dbe103c
to
01901bd
Compare
The following is the coverage report on pkg/.
|
👼
🤯 Brilliant. Thanks! |
the golang ci test is fallaciously green since it is actually failing but exit 0
This seems a recurring errors in golang-ci which i have updated the bug with our issue in here : |
01901bd
to
50cf5e7
Compare
The following is the coverage report on pkg/.
|
50cf5e7
to
1c2273e
Compare
The following is the coverage report on pkg/.
|
/test pull-tekton-pipeline-integration-tests |
Hey, can you please check what actual golangci version are you using? |
See tektoncd/plumbing#216 👼 |
/lgtm |
This adds auto-conversion methods and tests for Task types in v1alpha1 and v1alpha2. In order to reduce the number of duplicated fields, we are using v1alpha2.TaskSpec embedded in v1alpha1.TaskSpec so that both types are compatible. Signed-off-by: Vincent Demeester <[email protected]>
This adds auto-conversion methods and tests for Pipeline types in v1alpha1 and v1alpha2. Signed-off-by: Vincent Demeester <[email protected]>
This adds auto-conversion methods and tests for ClusterTask types in v1alpha1 and v1alpha2. Signed-off-by: Vincent Demeester <[email protected]>
The main reason is to not run into error forcing us to use the same receiver name for all function. The receiver name are different for a good reason. Signed-off-by: Vincent Demeester <[email protected]>
1c2273e
to
620c476
Compare
The following is the coverage report on pkg/.
|
/lgtm |
Changes
This adds:
and v1alpha2. In order to reduce the number of duplicated fields, we
are using v1alpha2.TaskSpec embedded in v1alpha1.TaskSpec so that both
types are compatible.
/cc @sbwsg @bobcatfish @afrittoli
Signed-off-by: Vincent Demeester [email protected]
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.