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

refactor trusted resources verification to move verification to reconcile #6502

Closed

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Apr 6, 2023

Changes

This commit refactor the trusted resources code, move verification logic from GetVerifiedTaskFunc and GetVerifiedPipelineFunc to reconcile. This will help to set the conditions for taskrun/pipelinerun.

/kind misc

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com

Submitter Checklist

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

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • 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

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesnt merit a release note. kind/misc Categorizes issue or PR as a miscellaneuous one. labels Apr 6, 2023
@tekton-robot tekton-robot requested review from bobcatfish and jerop April 6, 2023 03:32
@Yongxuanzhang
Copy link
Member Author

/test all

@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 6, 2023
@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/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.7% -0.3
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.7% -0.3
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@Yongxuanzhang
Copy link
Member Author

/test all

@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/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 89.4% -3.7
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.2
pkg/trustedresources/verify.go 95.2% 92.9% -2.4

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 89.4% -3.7
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.2
pkg/trustedresources/verify.go 95.2% 92.9% -2.4

@Yongxuanzhang
Copy link
Member Author

/test all

@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/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 89.4% -3.7
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.2
pkg/trustedresources/verify.go 95.2% 92.9% -2.4

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 89.4% -3.7
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.2
pkg/trustedresources/verify.go 95.2% 92.9% -2.4

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@Yongxuanzhang
Copy link
Member Author

/test all

@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/reconciler/pipelinerun/pipelinerun.go 88.8% 86.7% -2.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 6, 2023
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 87.7% -1.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@Yongxuanzhang Yongxuanzhang force-pushed the refactor-trusted-resources branch from 7ce383c to 81ba41c Compare April 6, 2023 20:21
@Yongxuanzhang
Copy link
Member Author

/test all

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 88.0% -0.7
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.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/reconciler/pipelinerun/pipelinerun.go 88.8% 88.0% -0.7
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@Yongxuanzhang Yongxuanzhang force-pushed the refactor-trusted-resources branch from 81ba41c to 0f4f4ca Compare April 6, 2023 20:33
@Yongxuanzhang
Copy link
Member Author

/test all

@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/reconciler/pipelinerun/pipelinerun.go 88.8% 88.2% -0.6
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 88.8% 88.2% -0.6
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 96.3% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.8% -0.1
pkg/trustedresources/verify.go 95.2% 92.2% -3.1

@Yongxuanzhang Yongxuanzhang changed the title refactor trusted resources verification to move verification to reconciler refactor trusted resources verification to move verification to reconcile Apr 27, 2023
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.1% 89.0% -0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.4% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.0% 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/reconciler/pipelinerun/pipelinerun.go 89.1% 89.0% -0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.4% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.0% 0.0

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.1% 89.0% -0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.4% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.0% 0.0

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Looking good! Few more cleanups/clarifications.

TaskName string
Kind v1beta1.TaskKind
TaskSpec *v1beta1.TaskSpec
Task *v1beta1.Task
Copy link
Member

Choose a reason for hiding this comment

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

Some of this data seems duplicated - e.g. wouldn't TaskSpec/Name be included in Task?

Copy link
Member Author

Choose a reason for hiding this comment

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

In cases like inline task&taskspec already in status, there is no "task" but we have the "taskSpec", so I think we cannot use task here to replace the other fields? Another reason is try to reduce the code changes

Copy link
Member

Choose a reason for hiding this comment

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

This is a bit confusing though because there are similar pieces of data and it's not clear when to use one over the other. e.g.

  • Task.spec vs TaskSpec
  • Task.ObjectMeta.Name vs TaskName
  • Task.TypeMeta.Kind vs Kind

If these are the same, then we should ideally just use a single type (probably Task). If they're different then we should document the differences and explain when you'd want to use each.

Copy link
Member Author

@Yongxuanzhang Yongxuanzhang May 1, 2023

Choose a reason for hiding this comment

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

Emmm, I agree there are similar pieces of data, it looks like some data may be contained in other data and this may get people confused.
But we probably cannot use Task.*** to replace TaskSpec, TaskName and Kind (correct me if I'm wrong), take this code for example:

if pipelineTask.TaskRef != nil {
// If the TaskRun has already a stored TaskSpec in its status, use it as source of truth
if taskRun != nil && taskRun.Status.TaskSpec != nil {
spec = *taskRun.Status.TaskSpec
taskName = pipelineTask.TaskRef.Name
} else {
// Following minimum status principle (TEP-0100), no need to propagate the RefSource about PipelineTask up to PipelineRun status.
// Instead, the child TaskRun's status will be the place recording the RefSource of individual task.
t, _, err = getTask(ctx, pipelineTask.TaskRef.Name)
switch {
case errors.Is(err, remote.ErrRequestInProgress):
return v1beta1.TaskSpec{}, "", "", err
case errors.Is(err, trustedresources.ErrResourceVerificationFailed):
return v1beta1.TaskSpec{}, "", "", err
case err != nil:
return v1beta1.TaskSpec{}, "", "", &TaskNotFoundError{
Name: pipelineTask.TaskRef.Name,
Msg: err.Error(),
}
default:
spec = t.TaskSpec()
taskName = t.TaskMetadata().Name
}
}
kind = pipelineTask.TaskRef.Kind
} else {
spec = pipelineTask.TaskSpec.TaskSpec

the TaskSpec is from *taskRun.Status.TaskSpec,
the taskName is from pipelineTask.TaskRef.Name and kind is from pipelineTask.TaskRef.Kind. There is no "Task" in the pipeline taskref case,

I will add doc strings for these fields to clarify. And maybe rename the Task to ReferredTask(since it is not inlined task)?

Comment on lines 421 to 428
vp, err := c.verificationPolicyLister.VerificationPolicies(pr.Namespace).List(labels.Everything())
if err != nil {
return fmt.Errorf("failed to list VerificationPolicies from namespace %s with error %w", pr.Namespace, err)
}
var refSourceURI string
if pipelineMeta.RefSource != nil {
refSourceURI = pipelineMeta.RefSource.URI
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks duplicated with the other verify calls. Should we just move this into the verify func if it's always needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

pkg/reconciler/pipelinerun/pipelinerun.go Outdated Show resolved Hide resolved
@Yongxuanzhang Yongxuanzhang force-pushed the refactor-trusted-resources branch from e747c3a to 1ed3a35 Compare April 27, 2023 17:07
@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/reconciler/pipelinerun/pipelinerun.go 89.1% 89.2% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.4% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.1% 89.2% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.4% -0.0
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@Yongxuanzhang Yongxuanzhang requested a review from wlynch April 27, 2023 18:46
@@ -703,7 +700,7 @@ func resolveTask(
} else {
spec = pipelineTask.TaskSpec.TaskSpec
}
return spec, taskName, kind, err
return spec, taskName, kind, t.DeepCopy(), refSource, err
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the ResolvedTask object below, could this be simplified to (*v1beta1.Task, *v1beta1.RefSource, error)?

  • task can come from t.TaskSpec
  • taskName can come from t.ObjectMeta.Name
  • kind can come from t.TypeMeta

Copy link
Member

Choose a reason for hiding this comment

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

Should this also be a ResolvedTask? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Should this also be a ResolvedTask? 🤔

🤔 Yeah that's a great suggestion, I think we could refactor this part of code a bit

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored the code to return a ResolvedTask here

TaskName string
Kind v1beta1.TaskKind
TaskSpec *v1beta1.TaskSpec
Task *v1beta1.Task
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit confusing though because there are similar pieces of data and it's not clear when to use one over the other. e.g.

  • Task.spec vs TaskSpec
  • Task.ObjectMeta.Name vs TaskName
  • Task.TypeMeta.Kind vs Kind

If these are the same, then we should ideally just use a single type (probably Task). If they're different then we should document the differences and explain when you'd want to use each.

pkg/reconciler/pipelinerun/pipelinerun.go Outdated Show resolved Hide resolved
if pipelineMeta != nil {
pipelineToBeVerified = &v1beta1.Pipeline{
ObjectMeta: *pipelineMeta.ObjectMeta,
Spec: *pipelineSpec,
Copy link
Member

Choose a reason for hiding this comment

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

These could panic if they're nil (same with taskToBeVerified below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean pipelineMeta.ObjectMeta and pipelineSpec could be nil? Both of them are from

func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getPipeline GetPipeline) (*resolutionutil.ResolvedObjectMeta, *v1beta1.PipelineSpec, error) {
pipelineMeta := metav1.ObjectMeta{}
var refSource *v1beta1.RefSource
pipelineSpec := v1beta1.PipelineSpec{}

and they are initialized so I think they cannot be nil?

Copy link
Member

Choose a reason for hiding this comment

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

That's not obvious from this func though 🙃

I think you should change this to:

if pipelineMeta != nil && pipelineSpec != nil {
	pipelineToBeVerified = &v1beta1.Pipeline{
		ObjectMeta: pipelineMeta.ObjectMeta,
		Spec:       *pipelineSpec,
	}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh ok, I will update

@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/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@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/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@Yongxuanzhang Yongxuanzhang requested a review from wlynch May 2, 2023 19:49
@Yongxuanzhang Yongxuanzhang force-pushed the refactor-trusted-resources branch from 1d2eadc to 9d1c684 Compare May 2, 2023 20:03
@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/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.3% 0.1
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

Comment on lines 32 to 38
TaskName string
Kind v1beta1.TaskKind
TaskSpec *v1beta1.TaskSpec
// PipelineResolvedTask is used to store the Pipeline resolved task for trusted resources verification
PipelineResolvedTask *v1beta1.Task
// RefSource is used to store the RefSource of Pipeline task
RefSource *v1beta1.RefSource
Copy link
Member

Choose a reason for hiding this comment

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

Same question as before - how should callers interpret the difference between overlapping fields TaskSpec and PipelineResolvedTask.TaskSpec, TaskName and PipelineResolvedTask.Name, etc.?

if pipelineMeta != nil {
pipelineToBeVerified = &v1beta1.Pipeline{
ObjectMeta: *pipelineMeta.ObjectMeta,
Spec: *pipelineSpec,
Copy link
Member

Choose a reason for hiding this comment

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

That's not obvious from this func though 🙃

I think you should change this to:

if pipelineMeta != nil && pipelineSpec != nil {
	pipelineToBeVerified = &v1beta1.Pipeline{
		ObjectMeta: pipelineMeta.ObjectMeta,
		Spec:       *pipelineSpec,
	}
}

…cile

This commit refactor the trusted resources code, move verification logic
from GetVerifiedTaskFunc and GetVerifiedPipelineFunc to reconcile. This
will help to set the conditions for taskrun/pipelinerun.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
@Yongxuanzhang Yongxuanzhang force-pushed the refactor-trusted-resources branch from 9d1c684 to d5daaab Compare May 3, 2023 19:55
@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/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.1% 88.9% -4.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.4% 96.7% 0.2
pkg/reconciler/taskrun/resources/taskref.go 89.7% 86.6% -3.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.2% 95.6% 0.3

@Yongxuanzhang
Copy link
Member Author

/hold We will try to refactor the code to not block v1

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/misc Categorizes issue or PR as a miscellaneuous one. release-note-none Denotes a PR that doesnt merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants