mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-10 23:00:48 -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
|
// Cache hit
|
||||||
a.logger.DebugContext(ctx, "Cache hit", log.String("key", cacheKey))
|
a.logger.DebugContext(ctx, "Cache hit", log.String("key", cacheKey))
|
||||||
return artifact.Reference{
|
return artifact.Reference{
|
||||||
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
|
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
|
||||||
Type: a.artifactOption.Type,
|
Type: a.artifactOption.Type,
|
||||||
ID: cacheKey,
|
ID: cacheKey,
|
||||||
BlobIDs: []string{cacheKey},
|
BlobIDs: []string{cacheKey},
|
||||||
|
RepoMetadata: a.repoMetadata,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,6 +276,15 @@ func TestArtifact_Inspect(t *testing.T) {
|
|||||||
BlobIDs: []string{
|
BlobIDs: []string{
|
||||||
"sha256:dc7c6039424c9fce969d3c2972d261af442a33f13e7494464386dbe280612d4c",
|
"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{
|
wantBlobInfo: &types.BlobInfo{
|
||||||
SchemaVersion: types.BlobJSONSchemaVersion,
|
SchemaVersion: types.BlobJSONSchemaVersion,
|
||||||
|
|||||||
Reference in New Issue
Block a user