mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-01 06:47:33 +02:00
remove root.json after getting the targets
This commit is contained in:
parent
851f61032a
commit
5e2598028f
@ -16,6 +16,8 @@
|
||||
package notary
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/notary"
|
||||
@ -74,6 +76,12 @@ func GetTargets(notaryEndpoint string, username string, fqRepo string) ([]Target
|
||||
} else if err != nil {
|
||||
return res, err
|
||||
}
|
||||
//Remove root.json such that when remote repository is removed the local cache can't be reused.
|
||||
rootJSON := path.Join(notaryCachePath, "tuf", fqRepo, "metadata/root.json")
|
||||
rmErr := os.Remove(rootJSON)
|
||||
if rmErr != nil {
|
||||
log.Warningf("Failed to clear cached root.json: %s, error: %v, when repo is removed from notary the signature status maybe incorrect")
|
||||
}
|
||||
for _, t := range targets {
|
||||
res = append(res, Target{t.Name, t.Hashes})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user