Skip to content

Commit bf39dc7

Browse files
authored
šŸ› update catalog status field being used for stale cache identification (#529)
* (bugfix): update catalog status field being used for stale cache identification Signed-off-by: Bryce Palmer <everettraven@gmail.com> * fix failing unit test Signed-off-by: Bryce Palmer <everettraven@gmail.com> --------- Signed-off-by: Bryce Palmer <everettraven@gmail.com>
1 parent b5c6bc9 commit bf39dc7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ā€Žinternal/catalogmetadata/cache/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *c
8484

8585
fsc.mutex.RLock()
8686
if data, ok := fsc.cacheDataByCatalogName[catalog.Name]; ok {
87-
if catalog.Status.ResolvedSource.Image.Ref == data.ResolvedRef {
87+
if catalog.Status.ResolvedSource.Image.ResolvedRef == data.ResolvedRef {
8888
fsc.mutex.RUnlock()
8989
return os.Open(cacheFilePath)
9090
}
@@ -143,7 +143,7 @@ func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *c
143143
}
144144

145145
fsc.cacheDataByCatalogName[catalog.Name] = cacheData{
146-
ResolvedRef: catalog.Status.ResolvedSource.Image.Ref,
146+
ResolvedRef: catalog.Status.ResolvedSource.Image.ResolvedRef,
147147
}
148148

149149
return file, nil

ā€Žinternal/catalogmetadata/cache/cache_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestCache(t *testing.T) {
7272
ResolvedSource: &catalogd.ResolvedCatalogSource{
7373
Type: catalogd.SourceTypeImage,
7474
Image: &catalogd.ResolvedImageSource{
75-
Ref: "fake/catalog@sha256:fakesha",
75+
ResolvedRef: "fake/catalog@sha256:fakesha",
7676
},
7777
},
7878
},
@@ -90,7 +90,7 @@ func TestCache(t *testing.T) {
9090
ResolvedSource: &catalogd.ResolvedCatalogSource{
9191
Type: catalogd.SourceTypeImage,
9292
Image: &catalogd.ResolvedImageSource{
93-
Ref: "fake/catalog@sha256:fakesha",
93+
ResolvedRef: "fake/catalog@sha256:fakesha",
9494
},
9595
},
9696
},
@@ -110,7 +110,7 @@ func TestCache(t *testing.T) {
110110
ResolvedSource: &catalogd.ResolvedCatalogSource{
111111
Type: catalogd.SourceTypeImage,
112112
Image: &catalogd.ResolvedImageSource{
113-
Ref: "fake/catalog@sha256:fakesha",
113+
ResolvedRef: "fake/catalog@sha256:fakesha",
114114
},
115115
},
116116
},
@@ -130,7 +130,7 @@ func TestCache(t *testing.T) {
130130
ResolvedSource: &catalogd.ResolvedCatalogSource{
131131
Type: catalogd.SourceTypeImage,
132132
Image: &catalogd.ResolvedImageSource{
133-
Ref: "fake/catalog@sha256:fakesha",
133+
ResolvedRef: "fake/catalog@sha256:fakesha",
134134
},
135135
},
136136
},
@@ -149,7 +149,7 @@ func TestCache(t *testing.T) {
149149
ResolvedSource: &catalogd.ResolvedCatalogSource{
150150
Type: catalogd.SourceTypeImage,
151151
Image: &catalogd.ResolvedImageSource{
152-
Ref: "fake/catalog@sha256:fakesha",
152+
ResolvedRef: "fake/catalog@sha256:fakesha",
153153
},
154154
},
155155
},
@@ -223,7 +223,7 @@ func TestCache(t *testing.T) {
223223

224224
if tt.testCaching {
225225
if !tt.shouldHitCache {
226-
tt.catalog.Status.ResolvedSource.Image.Ref = "fake/catalog@sha256:shafake"
226+
tt.catalog.Status.ResolvedSource.Image.ResolvedRef = "fake/catalog@sha256:shafake"
227227
}
228228
tt.tripper.content = append(tt.tripper.content, []byte(`{"schema": "olm.package", "name": "foobar"}`)...)
229229
rc, err := c.FetchCatalogContents(ctx, tt.catalog)

0 commit comments

Comments
Ā (0)