mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
fix(trivy): consistent coverage for reset method + longer wait time between retries (#1272)
Signed-off-by: Ana-Roberta Lisca <ana.kagome@yahoo.com>
This commit is contained in:
committed by
GitHub
parent
a2c34808a5
commit
5f026d2e80
@@ -1049,6 +1049,29 @@ func ReadLogFileAndSearchString(logPath string, stringToMatch string, timeout ti
|
||||
}
|
||||
}
|
||||
|
||||
func ReadLogFileAndCountStringOccurence(logPath string, stringToMatch string,
|
||||
timeout time.Duration, count int,
|
||||
) (bool, error) {
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancelFunc()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return false, nil
|
||||
default:
|
||||
content, err := os.ReadFile(logPath)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if strings.Count(string(content), stringToMatch) >= count {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CopyFile(sourceFilePath, destFilePath string) error {
|
||||
destFile, err := os.Create(destFilePath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user