Skip to content

Commit b162e8b

Browse files
chitrangpateltekton-robot
authored andcommitted
Add FeatureFlags field to TaskRun.Status.Provenance
This PR adds feature flags field to `TaskRun.Status.Provenance`. TEP0122 wants to add feature flags to `invocation.Environment` for completeness of build instructions.
1 parent 8407669 commit b162e8b

16 files changed

+159
-19
lines changed

pkg/apis/pipeline/v1/openapi_generated.go

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

pkg/apis/pipeline/v1/provenance.go

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ limitations under the License.
1313

1414
package v1
1515

16+
import "github.com/tektoncd/pipeline/pkg/apis/config"
17+
1618
// Provenance contains some key authenticated metadata about how a software artifact was
1719
// built (what sources, what inputs/outputs, etc.). For now, it only contains the subfield
1820
// `ConfigSource` that identifies the source where a build config file came from.
@@ -22,6 +24,9 @@ package v1
2224
type Provenance struct {
2325
// ConfigSource identifies the source where a resource came from.
2426
ConfigSource *ConfigSource `json:"configSource,omitempty"`
27+
28+
// FeatureFlags identifies the feature flags that were used during the task/pipeline run
29+
FeatureFlags *config.FeatureFlags `json:"featureFlags,omitempty"`
2530
}
2631

2732
// ConfigSource identifies the source where a resource came from.

pkg/apis/pipeline/v1/swagger.json

+4
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,10 @@
10361036
"configSource": {
10371037
"description": "ConfigSource identifies the source where a resource came from.",
10381038
"$ref": "#/definitions/v1.ConfigSource"
1039+
},
1040+
"featureFlags": {
1041+
"description": "FeatureFlags identifies the feature flags that were used during the task/pipeline run",
1042+
"$ref": "#/definitions/github.com.tektoncd.pipeline.pkg.apis.config.FeatureFlags"
10391043
}
10401044
}
10411045
},

pkg/apis/pipeline/v1/zz_generated.deepcopy.go

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

pkg/apis/pipeline/v1beta1/openapi_generated.go

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

pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/google/go-cmp/cmp"
2525
"github.com/google/go-cmp/cmp/cmpopts"
26+
"github.com/tektoncd/pipeline/pkg/apis/config"
2627
pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
2728
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
2829
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
@@ -309,6 +310,15 @@ func TestPipelineRunConversion(t *testing.T) {
309310
URI: "test-uri",
310311
Digest: map[string]string{"sha256": "digest"},
311312
},
313+
FeatureFlags: &config.FeatureFlags{
314+
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
315+
EnableAPIFields: config.DefaultEnableAPIFields,
316+
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
317+
ResourceVerificationMode: config.DefaultResourceVerificationMode,
318+
ResultExtractionMethod: config.DefaultResultExtractionMethod,
319+
MaxResultSize: config.DefaultMaxResultSize,
320+
CustomTaskVersion: config.DefaultCustomTaskVersion,
321+
},
312322
},
313323
},
314324
},

pkg/apis/pipeline/v1beta1/provenance.go

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ limitations under the License.
1313

1414
package v1beta1
1515

16+
import "github.com/tektoncd/pipeline/pkg/apis/config"
17+
1618
// Provenance contains some key authenticated metadata about how a software artifact was
1719
// built (what sources, what inputs/outputs, etc.). For now, it only contains the subfield
1820
// `ConfigSource` that identifies the source where a build config file came from.
@@ -22,6 +24,9 @@ package v1beta1
2224
type Provenance struct {
2325
// ConfigSource identifies the source where a resource came from.
2426
ConfigSource *ConfigSource `json:"configSource,omitempty"`
27+
28+
// FeatureFlags identifies the feature flags that were used during the task/pipeline run
29+
FeatureFlags *config.FeatureFlags `json:"featureFlags,omitempty"`
2530
}
2631

2732
// ConfigSource identifies the source where a resource came from.

pkg/apis/pipeline/v1beta1/provenance_conversion.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ import (
2020
)
2121

2222
func (p Provenance) convertTo(ctx context.Context, sink *v1.Provenance) {
23-
new := v1.ConfigSource{}
24-
p.ConfigSource.convertTo(ctx, &new)
25-
sink.ConfigSource = &new
23+
if p.ConfigSource != nil {
24+
new := v1.ConfigSource{}
25+
p.ConfigSource.convertTo(ctx, &new)
26+
sink.ConfigSource = &new
27+
}
28+
if p.FeatureFlags != nil {
29+
sink.FeatureFlags = p.FeatureFlags
30+
}
2631
}
2732

2833
func (p *Provenance) convertFrom(ctx context.Context, source v1.Provenance) {
29-
new := ConfigSource{}
30-
new.convertFrom(ctx, *source.ConfigSource)
31-
p.ConfigSource = &new
34+
if source.ConfigSource != nil {
35+
new := ConfigSource{}
36+
new.convertFrom(ctx, *source.ConfigSource)
37+
p.ConfigSource = &new
38+
}
39+
if source.FeatureFlags != nil {
40+
p.FeatureFlags = source.FeatureFlags
41+
}
3242
}
3343

3444
func (cs ConfigSource) convertTo(ctx context.Context, sink *v1.ConfigSource) {

pkg/apis/pipeline/v1beta1/swagger.json

+4
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,10 @@
16801680
"configSource": {
16811681
"description": "ConfigSource identifies the source where a resource came from.",
16821682
"$ref": "#/definitions/v1beta1.ConfigSource"
1683+
},
1684+
"featureFlags": {
1685+
"description": "FeatureFlags identifies the feature flags that were used during the task/pipeline run",
1686+
"$ref": "#/definitions/github.com.tektoncd.pipeline.pkg.apis.config.FeatureFlags"
16831687
}
16841688
}
16851689
},

pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/google/go-cmp/cmp"
25+
"github.com/tektoncd/pipeline/pkg/apis/config"
2526
pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
2627
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
2728
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
@@ -236,6 +237,15 @@ func TestTaskRunConversion(t *testing.T) {
236237
URI: "test-uri",
237238
Digest: map[string]string{"sha256": "digest"},
238239
},
240+
FeatureFlags: &config.FeatureFlags{
241+
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
242+
EnableAPIFields: config.DefaultEnableAPIFields,
243+
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
244+
ResourceVerificationMode: config.DefaultResourceVerificationMode,
245+
ResultExtractionMethod: config.DefaultResultExtractionMethod,
246+
MaxResultSize: config.DefaultMaxResultSize,
247+
CustomTaskVersion: config.DefaultCustomTaskVersion,
248+
},
239249
}},
240250
},
241251
},

pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go

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

pkg/reconciler/pipelinerun/pipelinerun.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -1264,11 +1264,14 @@ func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1beta1.PipelineRun,
12641264
// Propagate ConfigSource from remote resolution to PipelineRun Status
12651265
// This lives outside of the status.spec check to avoid the case where only the spec is available in the first reconcile and source comes in next reconcile.
12661266
cfg := config.FromContextOrDefaults(ctx)
1267-
if cfg.FeatureFlags.EnableProvenanceInStatus && meta != nil && meta.ConfigSource != nil {
1267+
if cfg.FeatureFlags.EnableProvenanceInStatus {
12681268
if pr.Status.Provenance == nil {
12691269
pr.Status.Provenance = &v1beta1.Provenance{}
12701270
}
1271-
if pr.Status.Provenance.ConfigSource == nil {
1271+
// Store FeatureFlags in the Provenance.
1272+
pr.Status.Provenance.FeatureFlags = cfg.FeatureFlags
1273+
1274+
if meta != nil && meta.ConfigSource != nil && pr.Status.Provenance.ConfigSource == nil {
12721275
pr.Status.Provenance.ConfigSource = meta.ConfigSource
12731276
}
12741277
}

pkg/reconciler/pipelinerun/pipelinerun_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -5029,6 +5029,16 @@ metadata:
50295029
PipelineSpec: ps.DeepCopy(),
50305030
Provenance: &v1beta1.Provenance{
50315031
ConfigSource: configSource.DeepCopy(),
5032+
FeatureFlags: &config.FeatureFlags{
5033+
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
5034+
EnableAPIFields: config.DefaultEnableAPIFields,
5035+
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
5036+
ResourceVerificationMode: config.DefaultResourceVerificationMode,
5037+
EnableProvenanceInStatus: true,
5038+
ResultExtractionMethod: config.DefaultResultExtractionMethod,
5039+
MaxResultSize: config.DefaultMaxResultSize,
5040+
CustomTaskVersion: config.DefaultCustomTaskVersion,
5041+
},
50325042
},
50335043
},
50345044
}

pkg/reconciler/taskrun/taskrun.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -957,17 +957,20 @@ func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1beta1.TaskRun, ts *v1b
957957
}
958958
}
959959

960-
// Propagate ConfigSource from remote resolution to TaskRun Status
961-
// This lives outside of the status.spec check to avoid the case where only the spec is available in the first reconcile and source comes in next reconcile.
962960
cfg := config.FromContextOrDefaults(ctx)
963-
if cfg.FeatureFlags.EnableProvenanceInStatus && meta != nil && meta.ConfigSource != nil {
961+
if cfg.FeatureFlags.EnableProvenanceInStatus {
964962
if tr.Status.Provenance == nil {
965963
tr.Status.Provenance = &v1beta1.Provenance{}
966964
}
967-
if tr.Status.Provenance.ConfigSource == nil {
965+
// Store FeatureFlags in the Provenance.
966+
tr.Status.Provenance.FeatureFlags = cfg.FeatureFlags
967+
// Propagate ConfigSource from remote resolution to TaskRun Status
968+
// This lives outside of the status.spec check to avoid the case where only the spec is available in the first reconcile and source comes in next reconcile.
969+
if meta != nil && meta.ConfigSource != nil && tr.Status.Provenance.ConfigSource == nil {
968970
tr.Status.Provenance.ConfigSource = meta.ConfigSource
969971
}
970972
}
973+
971974
return nil
972975
}
973976

pkg/reconciler/taskrun/taskrun_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -4159,6 +4159,16 @@ spec:
41594159
TaskSpec: ts.DeepCopy(),
41604160
Provenance: &v1beta1.Provenance{
41614161
ConfigSource: configSource.DeepCopy(),
4162+
FeatureFlags: &config.FeatureFlags{
4163+
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
4164+
EnableAPIFields: config.DefaultEnableAPIFields,
4165+
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
4166+
ResourceVerificationMode: config.DefaultResourceVerificationMode,
4167+
EnableProvenanceInStatus: true,
4168+
ResultExtractionMethod: config.DefaultResultExtractionMethod,
4169+
MaxResultSize: config.DefaultMaxResultSize,
4170+
CustomTaskVersion: config.DefaultCustomTaskVersion,
4171+
},
41624172
},
41634173
},
41644174
}

0 commit comments

Comments
 (0)