Skip to content

Commit

Permalink
more change
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-prindle committed Dec 13, 2023
1 parent 50a092c commit 0056ce8
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 51 deletions.
13 changes: 12 additions & 1 deletion pkg/chains/formats/slsa/v1/intotoite6.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ func (i *InTotoIte6) CreatePayload(ctx context.Context, obj interface{}) (interf
if err := prV1Beta1.ConvertFrom(ctx, pro.GetObject().(*v1.PipelineRun)); err != nil {
return nil, fmt.Errorf("error converting Tekton PipelineRun from version v1 to v1beta1: %s", err)
}
return pipelinerun.GenerateAttestation(ctx, objects.NewPipelineRunObjectV1Beta1(prV1Beta1), i.slsaConfig)
proV1Beta1 := objects.NewPipelineRunObjectV1Beta1(prV1Beta1)
// ====
trs := pro.GetTaskRuns()
for _, tr := range trs {
trV1Beta1 := &v1beta1.TaskRun{} //nolint:staticcheck
if err := trV1Beta1.ConvertFrom(ctx, tr); err != nil {
return nil, fmt.Errorf("error converting Tekton TaskRun from version v1 to v1beta1: %s", err)
}
proV1Beta1.AppendTaskRun(trV1Beta1)
}
// ====
return pipelinerun.GenerateAttestation(ctx, proV1Beta1, i.slsaConfig)
case *objects.TaskRunObjectV1Beta1:
logger.Infof("aprindle-42 - here")
return taskrun.GenerateAttestation(ctx, v, i.slsaConfig)
Expand Down
13 changes: 12 additions & 1 deletion pkg/chains/formats/slsa/v2alpha2/slsav2.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,18 @@ func (s *Slsa) CreatePayload(ctx context.Context, obj interface{}) (interface{},
if err := prV1Beta1.ConvertFrom(ctx, pro.GetObject().(*v1.PipelineRun)); err != nil {
return nil, fmt.Errorf("error converting Tekton PipelineRun from version v1 to v1beta1: %s", err)
}
return pipelinerun.GenerateAttestation(ctx, objects.NewPipelineRunObjectV1Beta1(prV1Beta1), s.slsaConfig)
proV1Beta1 := objects.NewPipelineRunObjectV1Beta1(prV1Beta1)
// ====
trs := pro.GetTaskRuns()
for _, tr := range trs {
trV1Beta1 := &v1beta1.TaskRun{} //nolint:staticcheck
if err := trV1Beta1.ConvertFrom(ctx, tr); err != nil {
return nil, fmt.Errorf("error converting Tekton TaskRun from version v1 to v1beta1: %s", err)
}
proV1Beta1.AppendTaskRun(trV1Beta1)
}
// ====
return pipelinerun.GenerateAttestation(ctx, proV1Beta1, s.slsaConfig)
case *objects.TaskRunObjectV1Beta1:
return taskrun.GenerateAttestation(ctx, v, s.slsaConfig)
case *objects.PipelineRunObjectV1Beta1:
Expand Down
5 changes: 5 additions & 0 deletions pkg/chains/objects/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ func (pro *PipelineRunObjectV1) AppendTaskRun(tr *v1.TaskRun) {
pro.taskRuns = append(pro.taskRuns, tr)
}

// Append TaskRuns to this PipelineRun
func (pro *PipelineRunObjectV1) GetTaskRuns() []*v1.TaskRun { //nolint:staticcheck
return pro.taskRuns
}

// Get the associated TaskRun via the Task name
func (pro *PipelineRunObjectV1) GetTaskRunFromTask(taskName string) *TaskRunObjectV1 {
for _, tr := range pro.taskRuns {
Expand Down
96 changes: 48 additions & 48 deletions test/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ type TestExample struct {
// https://github.com/tektoncd/pipeline/blob/main/test/examples_test.go
func TestExamples(t *testing.T) {
tests := []TestExample{
// {
// name: "taskrun-examples-slsa-v1",
// cm: map[string]string{
// "artifacts.taskrun.format": "slsa/v1",
// "artifacts.oci.storage": "tekton",
// },
// getExampleObjects: getTaskRunExamples,
// payloadKey: "chains.tekton.dev/payload-taskrun-%s",
// signatureKey: "chains.tekton.dev/signature-taskrun-%s",
// outputLocation: "slsa/v1",
// predicate: "slsav0.1",
// },
{
name: "taskrun-examples-slsa-v1",
cm: map[string]string{
"artifacts.taskrun.format": "slsa/v1",
"artifacts.oci.storage": "tekton",
},
getExampleObjects: getTaskRunExamples,
payloadKey: "chains.tekton.dev/payload-taskrun-%s",
signatureKey: "chains.tekton.dev/signature-taskrun-%s",
outputLocation: "slsa/v1",
predicate: "slsav0.1",
},
{
name: "pipelinerun-examples-slsa-v1",
cm: map[string]string{
Expand All @@ -95,42 +95,42 @@ func TestExamples(t *testing.T) {
outputLocation: "slsa/v1",
predicate: "slsav0.1",
},
// {
// name: "taskrun-examples-slsa-v2",
// cm: map[string]string{
// "artifacts.taskrun.format": "slsa/v2alpha1",
// "artifacts.oci.storage": "tekton",
// },
// getExampleObjects: getTaskRunExamples,
// payloadKey: "chains.tekton.dev/payload-taskrun-%s",
// signatureKey: "chains.tekton.dev/signature-taskrun-%s",
// outputLocation: "slsa/v2",
// predicate: "slsav0.2",
// },
// {
// name: "taskrun-examples-slsa-v2alpha2",
// cm: map[string]string{
// "artifacts.taskrun.format": "slsa/v2alpha2",
// "artifacts.oci.storage": "tekton",
// },
// getExampleObjects: getTaskRunExamples,
// payloadKey: "chains.tekton.dev/payload-taskrun-%s",
// signatureKey: "chains.tekton.dev/signature-taskrun-%s",
// outputLocation: "slsa/v2alpha2",
// predicate: "slsav1.0",
// },
// {
// name: "pipelinerun-examples-slsa-v2alpha2",
// cm: map[string]string{
// "artifacts.pipelinerun.format": "slsa/v2alpha2",
// "artifacts.oci.storage": "tekton",
// },
// getExampleObjects: getPipelineRunExamples,
// payloadKey: "chains.tekton.dev/payload-pipelinerun-%s",
// signatureKey: "chains.tekton.dev/signature-pipelinerun-%s",
// outputLocation: "slsa/v2alpha2",
// predicate: "slsav1.0",
// },
{
name: "taskrun-examples-slsa-v2",
cm: map[string]string{
"artifacts.taskrun.format": "slsa/v2alpha1",
"artifacts.oci.storage": "tekton",
},
getExampleObjects: getTaskRunExamples,
payloadKey: "chains.tekton.dev/payload-taskrun-%s",
signatureKey: "chains.tekton.dev/signature-taskrun-%s",
outputLocation: "slsa/v2",
predicate: "slsav0.2",
},
{
name: "taskrun-examples-slsa-v2alpha2",
cm: map[string]string{
"artifacts.taskrun.format": "slsa/v2alpha2",
"artifacts.oci.storage": "tekton",
},
getExampleObjects: getTaskRunExamples,
payloadKey: "chains.tekton.dev/payload-taskrun-%s",
signatureKey: "chains.tekton.dev/signature-taskrun-%s",
outputLocation: "slsa/v2alpha2",
predicate: "slsav1.0",
},
{
name: "pipelinerun-examples-slsa-v2alpha2",
cm: map[string]string{
"artifacts.pipelinerun.format": "slsa/v2alpha2",
"artifacts.oci.storage": "tekton",
},
getExampleObjects: getPipelineRunExamples,
payloadKey: "chains.tekton.dev/payload-pipelinerun-%s",
signatureKey: "chains.tekton.dev/signature-pipelinerun-%s",
outputLocation: "slsa/v2alpha2",
predicate: "slsav1.0",
},
}

for _, test := range tests {
Expand Down
4 changes: 3 additions & 1 deletion test/testdata/slsa/v2alpha2/pipeline-output-image.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
}
]
},
"timeout": "1h0m0s"
"timeouts": {
"pipeline": "1h0m0s"
}
}
},
"resolvedDependencies": [
Expand Down

0 comments on commit 0056ce8

Please sign in to comment.