Skip to content

Commit

Permalink
Fix nil-pointer when ConfigSource is missing (#736)
Browse files Browse the repository at this point in the history
If enable-provenance-in-status is set to "true" in the Tekton Pipelines
configuration, the PipelineRun.Status.Provenance fields is not nil, but
the PipelineRun.Status.Provenance.ConfigSource can be nil in some cases.

This change ensures a nil-pointer error does not occur in such cases.

Signed-off-by: Luiz Carvalho <[email protected]>
  • Loading branch information
lcarva authored Mar 8, 2023
1 parent 193cc97 commit ad16eb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func metadata(pro *objects.PipelineRunObject) *slsa.ProvenanceMetadata {
// add any Git specification to materials
func materials(pro *objects.PipelineRunObject, logger *zap.SugaredLogger) ([]slsa.ProvenanceMaterial, error) {
var mats []slsa.ProvenanceMaterial
if p := pro.Status.Provenance; p != nil {
if p := pro.Status.Provenance; p != nil && p.ConfigSource != nil {
m := slsa.ProvenanceMaterial{
URI: p.ConfigSource.URI,
Digest: p.ConfigSource.Digest,
Expand Down

0 comments on commit ad16eb4

Please sign in to comment.