Factor the Audita readiness check
This commit is contained in:
@@ -21,6 +21,23 @@ type Targets struct {
|
||||
Scriptorium []Target
|
||||
}
|
||||
|
||||
// CheckAudita runs the native provider check and retains its failure finding.
|
||||
func CheckAudita(ctx context.Context, checker AuditaChecker, request audita.PolishRequest) (Result, error) {
|
||||
var result Result
|
||||
if err := ctx.Err(); err != nil {
|
||||
return result, err
|
||||
}
|
||||
if checker == nil {
|
||||
return result, fmt.Errorf("audita preflight checker is required")
|
||||
}
|
||||
_, err := checker.Preflight(ctx, request)
|
||||
if err != nil {
|
||||
result.Findings = append(result.Findings, Finding{Severity: SeverityError, Stage: "polish", Message: "audita preflight: " + err.Error()})
|
||||
return result, errors.Join(fmt.Errorf("audita preflight: %w", err), ctx.Err())
|
||||
}
|
||||
return result, ctx.Err()
|
||||
}
|
||||
|
||||
// CheckNotarius retains native warnings and incomplete evidence separately
|
||||
// from the success decision; a ready assessment never overrides process failure.
|
||||
func CheckNotarius(ctx context.Context, checker notarius.ReadinessChecker, request notarius.ReadinessRequest) (Result, error) {
|
||||
@@ -83,16 +100,7 @@ func CheckDownstream(ctx context.Context, inspector Inspector, checker AuditaChe
|
||||
if !targets.Polish {
|
||||
return result, scriptErr
|
||||
}
|
||||
if checker == nil {
|
||||
return result, errors.Join(scriptErr, fmt.Errorf("audita preflight checker is required"))
|
||||
}
|
||||
_, err := checker.Preflight(ctx, polish)
|
||||
if err != nil {
|
||||
result.Findings = append(result.Findings, Finding{Severity: SeverityError, Stage: "polish", Message: "audita preflight: " + err.Error()})
|
||||
return result, errors.Join(scriptErr, fmt.Errorf("audita preflight: %w", err))
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return result, errors.Join(scriptErr, err)
|
||||
}
|
||||
return result, scriptErr
|
||||
auditaResult, auditaErr := CheckAudita(ctx, checker, polish)
|
||||
result.Findings = append(result.Findings, auditaResult.Findings...)
|
||||
return result, errors.Join(scriptErr, auditaErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user