From cd129ce82b7058b2e504e5616369770b44ee5d8e Mon Sep 17 00:00:00 2001 From: chaosinthecrd Date: Mon, 22 Jan 2024 13:52:44 +0000 Subject: [PATCH] finalising changes. Signed-off-by: chaosinthecrd --- attestation/context.go | 2 ++ run.go | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/attestation/context.go b/attestation/context.go index 8993db73..a30d8257 100644 --- a/attestation/context.go +++ b/attestation/context.go @@ -125,6 +125,8 @@ func (ctx *AttestationContext) RunAttestors() error { Reason: fmt.Sprintf("unknown run type %v", attestor.RunType()), } } + + attestors[attestor.RunType()] = append(attestors[attestor.RunType()], attestor) } for _, atts := range attestors { diff --git a/run.go b/run.go index b6ccd2ca..904bf90a 100644 --- a/run.go +++ b/run.go @@ -25,6 +25,7 @@ import ( "github.com/in-toto/go-witness/cryptoutil" "github.com/in-toto/go-witness/dsse" "github.com/in-toto/go-witness/intoto" + "github.com/in-toto/go-witness/log" ) type runOptions struct { @@ -85,6 +86,18 @@ func Run(stepName string, signer cryptoutil.Signer, opts ...RunOption) (RunResul return result, fmt.Errorf("failed to run attestors: %w", err) } + fail := false + for _, r := range runCtx.CompletedAttestors() { + if r.Error != nil { + fail = true + log.Errorf("attestor %s failed: %s", r.Attestor.Name(), r.Error) + } + } + + if fail { + return result, fmt.Errorf("attestors failed with errors") + } + result.Collection = attestation.NewCollection(ro.stepName, runCtx.CompletedAttestors()) result.SignedEnvelope, err = signCollection(result.Collection, dsse.SignWithSigners(ro.signer), dsse.SignWithTimestampers(ro.timestampers...)) if err != nil {