Skip to content

Commit ce2a9a4

Browse files
committed
Add Provenance field in TaskRun&PipelineRun status
Change 1: Add a Provenance field in TaskRun&PipelineRun status that currently only contains configsource data, but can be extended later to have more provenance-related fields. Change 2: Prior, tektoncd#5551 introduced the ConfigSource to api/resolution alpha & beta package. In this PR, we moved the ConfigSource to api/pipeline alpha & beta package for the provenance field to reuse that type (cannot import the api/resolution alpha because of import cycle). Why: See the motivation and discussions in tektoncd#5550. The tldr is that it helps pass provenance-related data in a more structured way ConfigSource is one example. Signed-off-by: Chuang Wang <chuangw@google.com>
1 parent b817d77 commit ce2a9a4

30 files changed

+519
-197
lines changed

docs/how-to-write-a-resolver.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ import (
191191

192192
"github.com/tektoncd/pipeline/pkg/resolution/resolver/framework"
193193
"knative.dev/pkg/injection/sharedmain"
194-
"github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1"
194+
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
195195
)
196196
```
197197

@@ -263,7 +263,7 @@ func (*myResolvedResource) Annotations() map[string]string {
263263

264264
// Source is the source reference of the remote data that records where the remote
265265
// file came from including the url, digest and the entrypoint. None atm.
266-
func (*myResolvedResource) Source() *v1alpha1.ConfigSource {
266+
func (*myResolvedResource) Source() *pipelinev1beta1.ConfigSource {
267267
return nil
268268
}
269269
```
@@ -276,7 +276,7 @@ following example.
276276
```go
277277
// Source is the source reference of the remote data that records where the remote
278278
// file came from including the url, digest and the entrypoint.
279-
func (*myResolvedResource) Source() *v1alpha1.ConfigSource {
279+
func (*myResolvedResource) Source() *pipelinev1beta1.ConfigSource {
280280
return &v1alpha1.ConfigSource{
281281
URI: "https://github.com/user/example",
282282
Digest: map[string]string{

docs/resolver-template/cmd/demoresolver/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"context"
1818
"errors"
1919

20+
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
2021
"github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1"
2122
"github.com/tektoncd/pipeline/pkg/resolution/common"
2223
"github.com/tektoncd/pipeline/pkg/resolution/resolver/framework"
@@ -94,6 +95,6 @@ func (*myResolvedResource) Annotations() map[string]string {
9495

9596
// Source is the source reference of the remote data that records where the remote
9697
// file came from including the url, digest and the entrypoint. None atm.
97-
func (*myResolvedResource) Source() *v1alpha1.ConfigSource {
98+
func (*myResolvedResource) Source() *pipelinev1beta1.ConfigSource {
9899
return nil
99100
}

go.sum

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/pipeline/v1/openapi_generated.go

+93-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/pipeline/v1/pipelinerun_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ type PipelineRunStatusFields struct {
427427
// FinallyStartTime is when all non-finally tasks have been completed and only finally tasks are being executed.
428428
// +optional
429429
FinallyStartTime *metav1.Time `json:"finallyStartTime,omitempty"`
430+
431+
// Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource
432+
Provenance *Provenance `json:"provenance,omitempty"`
430433
}
431434

432435
// SkippedTask is used to describe the Tasks that were skipped due to their When Expressions

pkg/apis/pipeline/v1/provenance.go

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2022 The Tekton Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package v1
15+
16+
// Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource
17+
type Provenance struct {
18+
Source *ConfigSource `json:"source,omitempty"`
19+
}
20+
21+
// ConfigSource records where the task/pipeline file came from.
22+
type ConfigSource struct {
23+
// URI indicating the identity of the source of the config.
24+
// https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI
25+
// Example: https://github.com/tektoncd/catalog
26+
URI string `json:"uri,omitempty"`
27+
28+
// Digest is a collection of cryptographic digests for the contents of the artifact specified by URI.
29+
// https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet
30+
// Example: {"sha1": "f99d13e554ffcb696dee719fa85b695cb5b0f428"}
31+
Digest map[string]string `json:"digest,omitempty"`
32+
33+
// EntryPoint identifying the entry point into the build. This is often a path to a
34+
// configuration file and/or a target label within that file.
35+
// Example: "task/git-clone/0.8/git-clone.yaml"
36+
EntryPoint string `json:"entryPoint,omitempty"`
37+
}

pkg/apis/pipeline/v1/swagger.json

+47
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,28 @@
169169
}
170170
}
171171
},
172+
"v1.ConfigSource": {
173+
"description": "ConfigSource records where the task/pipeline file came from.",
174+
"type": "object",
175+
"properties": {
176+
"digest": {
177+
"description": "Digest is a collection of cryptographic digests for the contents of the artifact specified by URI. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet Example: {\"sha1\": \"f99d13e554ffcb696dee719fa85b695cb5b0f428\"}",
178+
"type": "object",
179+
"additionalProperties": {
180+
"type": "string",
181+
"default": ""
182+
}
183+
},
184+
"entryPoint": {
185+
"description": "EntryPoint identifying the entry point into the build. This is often a path to a configuration file and/or a target label within that file. Example: \"task/git-clone/0.8/git-clone.yaml\"",
186+
"type": "string"
187+
},
188+
"uri": {
189+
"description": "URI indicating the identity of the source of the config. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI Example: https://github.com/tektoncd/catalog",
190+
"type": "string"
191+
}
192+
}
193+
},
172194
"v1.EmbeddedTask": {
173195
"description": "EmbeddedTask is used to define a Task inline within a Pipeline's PipelineTasks.",
174196
"type": "object",
@@ -643,6 +665,10 @@
643665
"description": "PipelineRunSpec contains the exact spec used to instantiate the run",
644666
"$ref": "#/definitions/v1.PipelineSpec"
645667
},
668+
"provenance": {
669+
"description": "Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource",
670+
"$ref": "#/definitions/v1.Provenance"
671+
},
646672
"results": {
647673
"description": "Results are the list of results written out by the pipeline task's containers",
648674
"type": "array",
@@ -692,6 +718,10 @@
692718
"description": "PipelineRunSpec contains the exact spec used to instantiate the run",
693719
"$ref": "#/definitions/v1.PipelineSpec"
694720
},
721+
"provenance": {
722+
"description": "Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource",
723+
"$ref": "#/definitions/v1.Provenance"
724+
},
695725
"results": {
696726
"description": "Results are the list of results written out by the pipeline task's containers",
697727
"type": "array",
@@ -988,6 +1018,15 @@
9881018
}
9891019
}
9901020
},
1021+
"v1.Provenance": {
1022+
"description": "Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource",
1023+
"type": "object",
1024+
"properties": {
1025+
"source": {
1026+
"$ref": "#/definitions/v1.ConfigSource"
1027+
}
1028+
}
1029+
},
9911030
"v1.ResolverRef": {
9921031
"description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.",
9931032
"type": "object",
@@ -1838,6 +1877,10 @@
18381877
"type": "string",
18391878
"default": ""
18401879
},
1880+
"provenance": {
1881+
"description": "Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource",
1882+
"$ref": "#/definitions/v1.Provenance"
1883+
},
18411884
"results": {
18421885
"description": "Results are the list of results written out by the task's containers",
18431886
"type": "array",
@@ -1900,6 +1943,10 @@
19001943
"type": "string",
19011944
"default": ""
19021945
},
1946+
"provenance": {
1947+
"description": "Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource",
1948+
"$ref": "#/definitions/v1.Provenance"
1949+
},
19031950
"results": {
19041951
"description": "Results are the list of results written out by the task's containers",
19051952
"type": "array",

pkg/apis/pipeline/v1/taskrun_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ type TaskRunStatusFields struct {
231231

232232
// TaskSpec contains the Spec from the dereferenced Task definition used to instantiate this TaskRun.
233233
TaskSpec *TaskSpec `json:"taskSpec,omitempty"`
234+
235+
// Provenance contains all the information that needs to be recorded in a provenance i.e. ConfigSource
236+
Provenance *Provenance `json:"provenance,omitempty"`
234237
}
235238

236239
// TaskRunStepSpec is used to override the values of a Step in the corresponding Task.

0 commit comments

Comments
 (0)