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

[TEP-0076]Add type for results #4779

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Apr 20, 2022

Changes

This commit is the first step of TEP-0076, to support array and object
in resutls we need to add type for TaskResult and TaskRunResult first.
Before this commit we don't have the Type for these results.

Besides, for we move the TaskResult and TaskRunResult into the centralized result_types.go, so it will be consistent with pararm_types.go

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

Add Type for TaskRunResult and TaskResult.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 88.9% 8.9
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.1% 0.0

@Yongxuanzhang
Copy link
Member Author

@ywluogg is this the right direction for first step?

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 88.9% 8.9
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.1% 0.0

@Yongxuanzhang
Copy link
Member Author

/assign @ywluogg

@tekton-robot
Copy link
Collaborator

@Yongxuanzhang: GitHub didn't allow me to assign the following users: ywluogg.

Note that only tektoncd members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @ywluogg

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.

pkg/apis/pipeline/v1beta1/swagger.json Show resolved Hide resolved
pkg/apis/pipeline/v1beta1/results.go Outdated Show resolved Hide resolved
Comment on lines 8 to 11
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see params for the similar file is called params_types.go. Maybe it worths being consistent with params?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is also something I'm not sure. I thought files ended with "_types" should have a crd in it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pretty good consideration. I think TaskResult is actually similar to ParamsSpec:

type ParamSpec struct {
and TaskRunResult is similar to Param:

Maybe we can move those structs into a centralized file results_types.go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that would also work, I can do it and see how other ppl think of it

pkg/apis/pipeline/v1beta1/taskrun_types.go Outdated Show resolved Hide resolved

// ResultsType indicates the type of a result;
// Used to distinguish between a single string and an array of strings.
type ResultsType string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should start having an interface for ResultType and ParamsType, as they ultimately need to be in ArrayOrString:

type ArrayOrString struct {

Pinging others @dibyom @vdemeester for more opinions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not moving them to ArrayOrString "now", as, from the API perspective (consumption) it doesn't change too much, all current API usage will still work because string is still supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I would suggest to add a TODO for changing this to have ResultType also in scope

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 88.9% 8.9
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.1% 0.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 88.9% 8.9
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.1% 0.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/result_defaults.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/result_validation.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 85.7% 5.7
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.0% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/result_defaults.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/result_validation.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 85.7% 5.7
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.0% -0.1

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review April 21, 2022 19:15
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 21, 2022
@ywluogg
Copy link
Contributor

ywluogg commented Apr 21, 2022

/test pull-tekton-pipeline-integration-tests

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-alpha-integration-tests

1 similar comment
@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-alpha-integration-tests

@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 22, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/result_defaults.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/result_validation.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 85.7% 5.7
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.0% -0.1

@tekton-robot tekton-robot removed the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 22, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, ywluogg

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 27, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/result_defaults.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/result_validation.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 85.7% 5.7
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.0% -0.1

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-alpha-integration-tests

1 similar comment
@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-alpha-integration-tests

pkg/apis/pipeline/v1beta1/result_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1beta1/result_types.go Show resolved Hide resolved
}
// Validate the result type
validType := false
for _, allowedType := range AllResultsTypes {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we've used sets.String elsewhere in the codebase, might be helpful here https://pkg.go.dev/k8s.io/apimachinery@v0.23.6/pkg/util/sets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was using map before, and I see param type is using a list. 😄 I will change it to sets.String

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emmm maybe I'm wrong, looks like I cannot use sets.String here, because sets.String is using string as key but we're using ResultsType

The following code will throw error
var AllResultsTypes = sets.String{ResultsTypeString:{}}

This commit is the first step of TEP-0076, to support array and object
in resutls we need to add type for TaskResult and TaskRunResult first.
Before this commit we don't have the Type for these results.
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/result_defaults.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/result_validation.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/task_defaults.go 80.0% 85.7% 5.7
pkg/apis/pipeline/v1beta1/task_validation.go 97.1% 97.0% -0.1

@lbernick
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2022
@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-alpha-integration-tests

@tekton-robot tekton-robot merged commit 6f39e94 into tektoncd:main Apr 29, 2022
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 27, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes this validation.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 27, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes this validation.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 28, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 29, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
tekton-robot pushed a commit that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
afrittoli pushed a commit to afrittoli/pipeline that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
tekton-robot pushed a commit that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
afrittoli pushed a commit to afrittoli/pipeline that referenced this pull request Jul 4, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
tekton-robot pushed a commit that referenced this pull request Jul 21, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants