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

Increase usage of TektonObject #881

Merged
merged 3 commits into from
Jul 25, 2023
Merged

Conversation

lcarva
Copy link
Contributor

@lcarva lcarva commented Jul 24, 2023

Changes

The first commit removes certain parts of the code that switch on the underlying TektonObject type to determine if either the string taskrun or pipelinerun should be used. Instead, a new method on TektonObject is used.

The second commit changes the code to no longer require callers to inspect the underlying type of the TektonObject to determine which Signable is supported. Instead, add a set of methods that specify which artifacts are supported. An alternative approach was consider to introduce a method such as TektonObject.GetSignables to return []artifacts.Signable. However, Signable already has a dependency on TektonObject causing a circular import.

Relates to #875

Submitter Checklist

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

  • Has Docs included if any changes are user facing
  • Has 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 updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

This commit removes certain parts of the code that switch on the
underlying TektonObject type to determine if either the string `taskrun`
or `pipelinerun` should be used. Instead, a new method on TektonObject
is used.

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 24, 2023
@tekton-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/chains/objects/objects.go 40.5% 38.6% -1.8
pkg/chains/storage/grafeas/grafeas.go 77.6% 78.2% 0.6

Change the code to no longer require callers to inspect the underlying
type of the TektonObject. Instead, add a set of methods that specify
which artifacts are supported.

An alternative approach was consider to introduce a method such as
`TektonObject.GetSignables` to return `[]artifacts.Signable`. However,
`Signable` already has a dependency on `TektonObject` causing a circular
import.

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
@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 Jul 24, 2023
@lcarva lcarva changed the title Add TektonObject.GetKindName to abstract more Increase usage of TektonObject Jul 24, 2023
@lcarva
Copy link
Contributor Author

lcarva commented Jul 24, 2023

@chitrangpatel, let me know what you think of this approach. It's a small step towards making it easier to support multiple versions of TaskRun and PipelineRun objects.

@tekton-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/chains/objects/objects.go 40.5% 34.0% -6.5
pkg/chains/signing.go 72.0% 73.7% 1.7
pkg/chains/storage/grafeas/grafeas.go 77.6% 78.2% 0.6

@chitrangpatel
Copy link
Contributor

Thanks @lcarva!!! This is amazing!

@chitrangpatel
Copy link
Contributor

Wondering if we can bump up the coverage of objects.go. Otherwise, lgtm.

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
@lcarva
Copy link
Contributor Author

lcarva commented Jul 25, 2023

Wondering if we can bump up the coverage of objects.go. Otherwise, lgtm.

Great catch! Added a new commit that covers all the functionality added, as well as some existing methods.

@tekton-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/chains/objects/objects.go 40.5% 66.0% 25.5
pkg/chains/signing.go 72.0% 73.7% 1.7
pkg/chains/storage/grafeas/grafeas.go 77.6% 78.2% 0.6

@chitrangpatel
Copy link
Contributor

/approve

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chitrangpatel

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 Jul 25, 2023
@chitrangpatel
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 25, 2023
@tekton-robot tekton-robot merged commit 13749f2 into tektoncd:main Jul 25, 2023
11 checks passed
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. 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.

3 participants