Skip to content

Commit

Permalink
dont stop validatin'
Browse files Browse the repository at this point in the history
hold on
  • Loading branch information
davdhacs committed Oct 31, 2024
1 parent bd73a4b commit 7e3909a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
18 changes: 10 additions & 8 deletions internal/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,16 @@ func walkDirScan(ctx context.Context, cfg *types.Config, tag *v1.TagReference, c
klog.V(1).InfoS("scanning success", "image", getImage(res), "path", innerPath, "status", "success")
} else {
status := res.Status()
klog.InfoS("scanning "+status,
"image", getImage(res),
"path", innerPath,
"error", res.Error.Error,
"component", getComponent(res),
"tag", getTag(res),
"rpm", res.RPM,
"status", status)
for _, err := range res.Errors {
klog.InfoS("scanning "+status,
"image", getImage(res),
"path", innerPath,
"error", err.Error,
"component", getComponent(res),
"tag", getTag(res),
"rpm", res.RPM,
"status", status)
}
}
results.Append(res)
return nil
Expand Down
1 change: 1 addition & 0 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type ScanResult struct {
Path string
Skip bool
Error *ValidationError
Errors []*ValidationError
}

type ScanResults struct {
Expand Down
7 changes: 6 additions & 1 deletion internal/types/types_scan_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ func (r *ScanResult) SetOS(info OSInfo) *ScanResult {
}

func (r *ScanResult) SetValidationError(err *ValidationError) *ScanResult {
r.Error = err
if r.Error != nil {
r.Errors = append(r.Errors, err)
} else {
r.Error = err
r.Errors = append(r.Errors, err)
}
return r
}

Expand Down
7 changes: 5 additions & 2 deletions internal/validations/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ checks:
// See if the error is to be ignored.
for _, list := range errIgnores {
if list.Ignore(innerPath, err.Error) {
klog.Info("ignoring %s for ", err.Error, innerPath)
continue checks
}
}
Expand All @@ -432,10 +433,12 @@ checks:
}
}
}
return res.SetValidationError(err)
res.SetValidationError(err)
}
}

if res.Error != nil {
return res
}
return res.Success()
}

Expand Down

0 comments on commit 7e3909a

Please sign in to comment.