Migrate audit reports to the files table
Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -1468,16 +1468,16 @@ func (r *Resolver) GetAuditTool(ctx context.Context, req *mcp.CallToolRequest, i
|
||||
return nil, types.GetAuditOutput{}, fmt.Errorf("cannot get audit: %w", err)
|
||||
}
|
||||
|
||||
var report *coredata.Report
|
||||
if audit.ReportID != nil {
|
||||
report, err = prb.Reports.Get(ctx, scope, *audit.ReportID)
|
||||
var file *coredata.File
|
||||
if audit.ReportFileID != nil {
|
||||
file, err = prb.Files.Get(ctx, scope, *audit.ReportFileID)
|
||||
if err != nil {
|
||||
return nil, types.GetAuditOutput{}, fmt.Errorf("cannot get audit report: %w", err)
|
||||
return nil, types.GetAuditOutput{}, fmt.Errorf("cannot get audit report file: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, types.GetAuditOutput{
|
||||
Audit: types.NewAudit(audit, report),
|
||||
Audit: types.NewAudit(audit, file),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1532,16 +1532,16 @@ func (r *Resolver) UpdateAuditTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
return nil, types.UpdateAuditOutput{}, fmt.Errorf("cannot update audit: %w", err)
|
||||
}
|
||||
|
||||
var report *coredata.Report
|
||||
if audit.ReportID != nil {
|
||||
report, err = svc.Reports.Get(ctx, scope, *audit.ReportID)
|
||||
var file *coredata.File
|
||||
if audit.ReportFileID != nil {
|
||||
file, err = svc.Files.Get(ctx, scope, *audit.ReportFileID)
|
||||
if err != nil {
|
||||
return nil, types.UpdateAuditOutput{}, fmt.Errorf("cannot get audit report: %w", err)
|
||||
return nil, types.UpdateAuditOutput{}, fmt.Errorf("cannot get audit report file: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, types.UpdateAuditOutput{
|
||||
Audit: types.NewAudit(audit, report),
|
||||
Audit: types.NewAudit(audit, file),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
func NewAudit(a *coredata.Audit, report *coredata.Report) *Audit {
|
||||
func NewAudit(a *coredata.Audit, file *coredata.File) *Audit {
|
||||
audit := &Audit{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
@@ -27,16 +27,16 @@ func NewAudit(a *coredata.Audit, report *coredata.Report) *Audit {
|
||||
FrameworkID: a.FrameworkID,
|
||||
State: a.State,
|
||||
TrustCenterVisibility: a.TrustCenterVisibility,
|
||||
HasReport: a.ReportID != nil,
|
||||
HasReport: a.ReportFileID != nil,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
}
|
||||
|
||||
if report != nil {
|
||||
audit.ReportFilename = &report.Filename
|
||||
audit.ReportMimeType = &report.MimeType
|
||||
if file != nil {
|
||||
audit.ReportFilename = &file.FileName
|
||||
audit.ReportMimeType = &file.MimeType
|
||||
}
|
||||
|
||||
return audit
|
||||
|
||||
Reference in New Issue
Block a user