@@ -16,7 +16,6 @@ import (
16
16
"github.com/aws/aws-sdk-go/service/ecr"
17
17
"github.com/aws/aws-sdk-go/service/ecr/ecriface"
18
18
ctypes "github.com/containers/image/v5/types"
19
- "github.com/dgraph-io/ristretto"
20
19
"github.com/estahn/k8s-image-swapper/pkg/backend"
21
20
"github.com/estahn/k8s-image-swapper/pkg/config"
22
21
"github.com/go-co-op/gocron"
@@ -27,7 +26,6 @@ type ECRClient struct {
27
26
client ecriface.ECRAPI
28
27
ecrDomain string
29
28
authToken []byte
30
- cache * ristretto.Cache
31
29
scheduler * gocron.Scheduler
32
30
targetAccount string
33
31
accessPolicy string
@@ -36,7 +34,7 @@ type ECRClient struct {
36
34
backend backend.Backend
37
35
}
38
36
39
- func NewECRClient (clientConfig config.AWS , imageBackend backend.Backend , cache * ristretto. Cache ) (* ECRClient , error ) {
37
+ func NewECRClient (clientConfig config.AWS , imageBackend backend.Backend ) (* ECRClient , error ) {
40
38
ecrDomain := clientConfig .EcrDomain ()
41
39
42
40
var sess * session.Session
@@ -73,7 +71,6 @@ func NewECRClient(clientConfig config.AWS, imageBackend backend.Backend, cache *
73
71
client := & ECRClient {
74
72
client : ecrClient ,
75
73
ecrDomain : ecrDomain ,
76
- cache : cache ,
77
74
scheduler : scheduler ,
78
75
targetAccount : clientConfig .AccountID ,
79
76
accessPolicy : clientConfig .ECROptions .AccessPolicy ,
@@ -94,10 +91,6 @@ func (e *ECRClient) Credentials() string {
94
91
}
95
92
96
93
func (e * ECRClient ) CreateRepository (ctx context.Context , name string ) error {
97
- if _ , found := e .cache .Get (name ); found {
98
- return nil
99
- }
100
-
101
94
log .Ctx (ctx ).Debug ().Str ("repository" , name ).Msg ("create repository" )
102
95
103
96
_ , err := e .client .CreateRepositoryWithContext (ctx , & ecr.CreateRepositoryInput {
@@ -153,8 +146,6 @@ func (e *ECRClient) CreateRepository(ctx context.Context, name string) error {
153
146
}
154
147
}
155
148
156
- e .cache .Set (name , "" , 1 )
157
-
158
149
return nil
159
150
}
160
151
@@ -189,12 +180,6 @@ func (e *ECRClient) ImageExists(ctx context.Context, imageRef ctypes.ImageRefere
189
180
Creds : e .Credentials (),
190
181
}
191
182
192
- ref := imageRef .DockerReference ().String ()
193
- if _ , found := e .cache .Get (ref ); found {
194
- log .Ctx (ctx ).Trace ().Str ("ref" , ref ).Msg ("found in cache" )
195
- return true
196
- }
197
-
198
183
exists , err := e .backend .Exists (ctx , imageRef , creds )
199
184
if err != nil {
200
185
log .Error ().Err (err ).Msg ("unable to check existence of image" )
@@ -266,7 +251,6 @@ func NewMockECRClient(ecrClient ecriface.ECRAPI, region string, ecrDomain string
266
251
client := & ECRClient {
267
252
client : ecrClient ,
268
253
ecrDomain : ecrDomain ,
269
- cache : nil ,
270
254
scheduler : nil ,
271
255
targetAccount : targetAccount ,
272
256
authToken : []byte ("mock-ecr-client-fake-auth-token" ),
0 commit comments