Skip to content

Commit

Permalink
move trusted resources verification after we resolve the remote resou…
Browse files Browse the repository at this point in the history
…rces

This PR moves the trusted resources verification to
readRuntimeObjectAsTask and readRuntimeObjectAsPipline, the reasons we
need this change include 1) unblock the work for v1, since v1 will
mutate, validate and convert the resources, the mutation will break
trusted resources verification thus we need to verify right after we
resolve the remote resources. 2) Prepare the support for verifying
different api versions. This commit also makes it clear that currently
we only support verification for remote resources.

Signed-off-by: Yongxuan Zhang [email protected]
  • Loading branch information
Yongxuanzhang authored and tekton-robot committed May 10, 2023
1 parent 43b9078 commit 77f7d0f
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 294 deletions.
4 changes: 3 additions & 1 deletion docs/trusted-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ weight: 312

## Overview

Trusted Resources is a feature which can be used to sign Tekton Resources and verify them. Details of design can be found at [TEP--0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md). This feature is under `alpha` version and support `v1beta1` version of `Task` and `Pipeline`.
Trusted Resources is a feature which can be used to sign Tekton Resources and verify them. Details of design can be found at [TEP--0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md). This is an alpha feature and supports `v1beta1` version of `Task` and `Pipeline`.

**Note**: Currently, trusted resources only support verifying Tekton resources that come from remote places i.e. git, OCI registry and Artifact Hub. To use [cluster resolver](./cluster-resolver.md) for in-cluster resources, make sure to set all default values for the resources before applied to cluster, because the mutating webhook will update the default fields if not given and fail the verification.

Verification failure will mark corresponding taskrun/pipelinerun as Failed status and stop the execution.

Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, pr *v1beta1.PipelineRun)
if err != nil {
return fmt.Errorf("failed to list VerificationPolicies from namespace %s with error %w", pr.Namespace, err)
}
getPipelineFunc := resources.GetVerifiedPipelineFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, vp)
getPipelineFunc := resources.GetPipelineFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, vp)

if pr.IsDone() {
pr.SetDefaults(ctx)
Expand Down Expand Up @@ -331,7 +331,7 @@ func (c *Reconciler) resolvePipelineState(
if err != nil {
return nil, fmt.Errorf("failed to list VerificationPolicies from namespace %s with error %w", pr.Namespace, err)
}
fn := tresources.GetVerifiedTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.ServiceAccountName, vp)
fn := tresources.GetTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.ServiceAccountName, vp)

getRunObjectFunc := func(name string) (v1beta1.RunObject, error) {
r, err := c.customRunLister.CustomRuns(pr.Namespace).Get(name)
Expand Down
Loading

0 comments on commit 77f7d0f

Please sign in to comment.