forked from aquasecurity/fanal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.go
46 lines (35 loc) · 1.39 KB
/
cache.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cache
import (
"github.com/aquasecurity/fanal/types"
)
const (
cacheDirName = "fanal"
// artifactBucket stores artifact information with artifact ID such as image ID
artifactBucket = "artifact"
// blobBucket stores os, package and library information per blob ID such as layer ID
blobBucket = "blob"
)
type Cache interface {
ArtifactCache
LocalArtifactCache
}
// ArtifactCache uses local or remote cache
type ArtifactCache interface {
// MissingBlobs returns missing blob IDs such as layer IDs in cache
MissingBlobs(artifactID string, blobIDs []string) (missingArtifact bool, missingBlobIDs []string, err error)
// PutArtifact stores artifact information such as image metadata in cache
PutArtifact(artifactID string, artifactInfo types.ArtifactInfo) (err error)
// PutBlob stores blob information such as layer information in local cache
PutBlob(blobID string, blobInfo types.BlobInfo) (err error)
}
// LocalArtifactCache always uses local cache
type LocalArtifactCache interface {
// GetArtifact gets artifact information such as image metadata from local cache
GetArtifact(artifactID string) (artifactInfo types.ArtifactInfo, err error)
// GetBlob gets blob information such as layer data from local cache
GetBlob(blobID string) (blobInfo types.BlobInfo, err error)
// Close closes the local database
Close() (err error)
// Clear deletes the local database
Clear() (err error)
}