11package cache
22
33import (
4+ "context"
45 "encoding/json"
56 "errors"
67 "os"
@@ -63,7 +64,7 @@ func NewFSCache(cacheDir string) (FSCache, error) {
6364}
6465
6566// GetBlob gets blob information such as layer data from local cache
66- func (fs FSCache ) GetBlob (blobID string ) (types.BlobInfo , error ) {
67+ func (fs FSCache ) GetBlob (_ context. Context , blobID string ) (types.BlobInfo , error ) {
6768 var blobInfo types.BlobInfo
6869 err := fs .db .View (func (tx * bolt.Tx ) error {
6970 var err error
@@ -91,7 +92,7 @@ func (fs FSCache) getBlob(blobBucket *bolt.Bucket, diffID string) (types.BlobInf
9192}
9293
9394// PutBlob stores blob information such as layer information in local cache
94- func (fs FSCache ) PutBlob (blobID string , blobInfo types.BlobInfo ) error {
95+ func (fs FSCache ) PutBlob (_ context. Context , blobID string , blobInfo types.BlobInfo ) error {
9596 b , err := json .Marshal (blobInfo )
9697 if err != nil {
9798 return xerrors .Errorf ("unable to marshal blob JSON (%s): %w" , blobID , err )
@@ -111,7 +112,7 @@ func (fs FSCache) PutBlob(blobID string, blobInfo types.BlobInfo) error {
111112}
112113
113114// GetArtifact gets artifact information such as image metadata from local cache
114- func (fs FSCache ) GetArtifact (artifactID string ) (types.ArtifactInfo , error ) {
115+ func (fs FSCache ) GetArtifact (_ context. Context , artifactID string ) (types.ArtifactInfo , error ) {
115116 var blob []byte
116117 err := fs .db .View (func (tx * bolt.Tx ) error {
117118 artifactBucket := tx .Bucket ([]byte (artifactBucket ))
@@ -130,7 +131,7 @@ func (fs FSCache) GetArtifact(artifactID string) (types.ArtifactInfo, error) {
130131}
131132
132133// DeleteBlobs removes blobs by IDs
133- func (fs FSCache ) DeleteBlobs (blobIDs []string ) error {
134+ func (fs FSCache ) DeleteBlobs (_ context. Context , blobIDs []string ) error {
134135 var errs error
135136 err := fs .db .Update (func (tx * bolt.Tx ) error {
136137 bucket := tx .Bucket ([]byte (blobBucket ))
@@ -148,7 +149,7 @@ func (fs FSCache) DeleteBlobs(blobIDs []string) error {
148149}
149150
150151// PutArtifact stores artifact information such as image metadata in local cache
151- func (fs FSCache ) PutArtifact (artifactID string , artifactInfo types.ArtifactInfo ) (err error ) {
152+ func (fs FSCache ) PutArtifact (_ context. Context , artifactID string , artifactInfo types.ArtifactInfo ) (err error ) {
152153 b , err := json .Marshal (artifactInfo )
153154 if err != nil {
154155 return xerrors .Errorf ("unable to marshal artifact JSON (%s): %w" , artifactID , err )
@@ -169,7 +170,7 @@ func (fs FSCache) PutArtifact(artifactID string, artifactInfo types.ArtifactInfo
169170}
170171
171172// MissingBlobs returns missing blob IDs such as layer IDs
172- func (fs FSCache ) MissingBlobs (artifactID string , blobIDs []string ) (bool , []string , error ) {
173+ func (fs FSCache ) MissingBlobs (ctx context. Context , artifactID string , blobIDs []string ) (bool , []string , error ) {
173174 var missingArtifact bool
174175 var missingBlobIDs []string
175176 err := fs .db .View (func (tx * bolt.Tx ) error {
@@ -192,7 +193,7 @@ func (fs FSCache) MissingBlobs(artifactID string, blobIDs []string) (bool, []str
192193 }
193194
194195 // get artifact info
195- artifactInfo , err := fs .GetArtifact (artifactID )
196+ artifactInfo , err := fs .GetArtifact (ctx , artifactID )
196197 if err != nil {
197198 // error means cache missed artifact info
198199 return true , missingBlobIDs , nil
@@ -212,7 +213,7 @@ func (fs FSCache) Close() error {
212213}
213214
214215// Clear removes the database
215- func (fs FSCache ) Clear () error {
216+ func (fs FSCache ) Clear (_ context. Context ) error {
216217 if err := fs .Close (); err != nil {
217218 return err
218219 }
0 commit comments