mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-05 20:40:16 -08:00
fix(repo): preserve RepoMetadata on FS cache hit (#9389)
This commit is contained in:
@@ -190,10 +190,11 @@ func (a Artifact) Inspect(ctx context.Context) (artifact.Reference, error) {
|
||||
// Cache hit
|
||||
a.logger.DebugContext(ctx, "Cache hit", log.String("key", cacheKey))
|
||||
return artifact.Reference{
|
||||
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
|
||||
Type: a.artifactOption.Type,
|
||||
ID: cacheKey,
|
||||
BlobIDs: []string{cacheKey},
|
||||
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
|
||||
Type: a.artifactOption.Type,
|
||||
ID: cacheKey,
|
||||
BlobIDs: []string{cacheKey},
|
||||
RepoMetadata: a.repoMetadata,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +276,15 @@ func TestArtifact_Inspect(t *testing.T) {
|
||||
BlobIDs: []string{
|
||||
"sha256:dc7c6039424c9fce969d3c2972d261af442a33f13e7494464386dbe280612d4c",
|
||||
},
|
||||
RepoMetadata: artifact.RepoMetadata{
|
||||
RepoURL: "https://github.com/aquasecurity/trivy-test-repo/",
|
||||
Branch: "main",
|
||||
Tags: []string{"v0.0.1"},
|
||||
Commit: "8a19b492a589955c3e70c6ad8efd1e4ec6ae0d35",
|
||||
CommitMsg: "Update README.md",
|
||||
Author: "Teppei Fukuda <knqyf263@gmail.com>",
|
||||
Committer: "GitHub <noreply@github.com>",
|
||||
},
|
||||
},
|
||||
wantBlobInfo: &types.BlobInfo{
|
||||
SchemaVersion: types.BlobJSONSchemaVersion,
|
||||
|
||||
Reference in New Issue
Block a user