Skip to content

Commit 7d64f4e

Browse files
authored
chore: extract image cache type (#11968)
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
1 parent 1b5f68a commit 7d64f4e

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎sensor/common/detector/detector.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/stackrox/rox/pkg/env"
2020
"github.com/stackrox/rox/pkg/errorhelpers"
2121
"github.com/stackrox/rox/pkg/errox"
22-
"github.com/stackrox/rox/pkg/expiringcache"
2322
"github.com/stackrox/rox/pkg/features"
2423
"github.com/stackrox/rox/pkg/logging"
2524
"github.com/stackrox/rox/pkg/networkgraph"
@@ -73,7 +72,7 @@ type Detector interface {
7372

7473
// New returns a new detector
7574
func New(enforcer enforcer.Enforcer, admCtrlSettingsMgr admissioncontroller.SettingsManager,
76-
deploymentStore store.DeploymentStore, serviceAccountStore store.ServiceAccountStore, cache expiringcache.Cache, auditLogEvents chan *sensor.AuditEvents,
75+
deploymentStore store.DeploymentStore, serviceAccountStore store.ServiceAccountStore, cache imagecacheutils.ImageCache, auditLogEvents chan *sensor.AuditEvents,
7776
auditLogUpdater updater.Component, networkPolicyStore store.NetworkPolicyStore, registryStore *registry.Store, localScan *scan.LocalScan) Detector {
7877
detectorStopper := concurrency.NewStopper()
7978
netFlowQueueSize := 0

‎sensor/common/detector/enricher.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/stackrox/rox/pkg/booleanpolicy/augmentedobjs"
1414
"github.com/stackrox/rox/pkg/concurrency"
1515
"github.com/stackrox/rox/pkg/env"
16-
"github.com/stackrox/rox/pkg/expiringcache"
1716
"github.com/stackrox/rox/pkg/features"
1817
"github.com/stackrox/rox/pkg/images/types"
1918
"github.com/stackrox/rox/pkg/protoutils"
@@ -50,7 +49,7 @@ type enricher struct {
5049

5150
serviceAccountStore store.ServiceAccountStore
5251
localScan *scan.LocalScan
53-
imageCache expiringcache.Cache
52+
imageCache imagecacheutils.ImageCache
5453
stopSig concurrency.Signal
5554
regStore *registry.Store
5655
}
@@ -229,7 +228,7 @@ func (c *cacheValue) updateImageNoLock(image *storage.Image) {
229228
c.image.Names = protoutils.SliceUnique(append(c.image.GetNames(), existingNames...))
230229
}
231230

232-
func newEnricher(cache expiringcache.Cache, serviceAccountStore store.ServiceAccountStore, registryStore *registry.Store, localScan *scan.LocalScan) *enricher {
231+
func newEnricher(cache imagecacheutils.ImageCache, serviceAccountStore store.ServiceAccountStore, registryStore *registry.Store, localScan *scan.LocalScan) *enricher {
233232
return &enricher{
234233
scanResultChan: make(chan scanResult),
235234
serviceAccountStore: serviceAccountStore,

‎sensor/common/image/service_impl.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/stackrox/rox/generated/storage"
1212
"github.com/stackrox/rox/pkg/centralsensor"
1313
"github.com/stackrox/rox/pkg/concurrency"
14-
"github.com/stackrox/rox/pkg/expiringcache"
1514
grpcPkg "github.com/stackrox/rox/pkg/grpc"
1615
"github.com/stackrox/rox/pkg/grpc/authz/idcheck"
1716
"github.com/stackrox/rox/pkg/logging"
@@ -44,7 +43,7 @@ type ServiceComponent interface {
4443
}
4544

4645
// NewService returns the ImageService API for the Admission Controller to use.
47-
func NewService(imageCache expiringcache.Cache, registryStore registryStore, mirrorStore registrymirror.Store) ServiceComponent {
46+
func NewService(imageCache imagecacheutils.ImageCache, registryStore registryStore, mirrorStore registrymirror.Store) ServiceComponent {
4847
return &serviceImpl{
4948
imageCache: imageCache,
5049
registryStore: registryStore,
@@ -57,7 +56,7 @@ type serviceImpl struct {
5756
sensor.UnimplementedImageServiceServer
5857

5958
centralClient centralClient
60-
imageCache expiringcache.Cache
59+
imageCache imagecacheutils.ImageCache
6160
registryStore registryStore
6261
localScan localScan
6362
centralReady concurrency.Signal

‎sensor/common/imagecacheutils/common.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package imagecacheutils
22

3-
import "github.com/stackrox/rox/generated/storage"
3+
import (
4+
"github.com/stackrox/rox/generated/storage"
5+
"github.com/stackrox/rox/pkg/expiringcache"
6+
)
7+
8+
type ImageCache expiringcache.Cache
49

510
// CacheKeyProvider represents an interface from which image cache can be generated.
611
type CacheKeyProvider interface {

‎sensor/common/reprocessor/handler.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"github.com/stackrox/rox/generated/internalapi/central"
66
"github.com/stackrox/rox/pkg/centralsensor"
77
"github.com/stackrox/rox/pkg/concurrency"
8-
"github.com/stackrox/rox/pkg/expiringcache"
98
"github.com/stackrox/rox/pkg/logging"
109
"github.com/stackrox/rox/sensor/common"
1110
"github.com/stackrox/rox/sensor/common/admissioncontroller"
1211
"github.com/stackrox/rox/sensor/common/detector"
12+
"github.com/stackrox/rox/sensor/common/imagecacheutils"
1313
"github.com/stackrox/rox/sensor/common/message"
1414
)
1515

@@ -27,7 +27,7 @@ type Handler interface {
2727
}
2828

2929
// NewHandler returns a new instance of a deployment reprocessor.
30-
func NewHandler(admCtrlSettingsMgr admissioncontroller.SettingsManager, detector detector.Detector, imageCache expiringcache.Cache) Handler {
30+
func NewHandler(admCtrlSettingsMgr admissioncontroller.SettingsManager, detector detector.Detector, imageCache imagecacheutils.ImageCache) Handler {
3131
return &handlerImpl{
3232
admCtrlSettingsMgr: admCtrlSettingsMgr,
3333
detector: detector,
@@ -39,7 +39,7 @@ func NewHandler(admCtrlSettingsMgr admissioncontroller.SettingsManager, detector
3939
type handlerImpl struct {
4040
admCtrlSettingsMgr admissioncontroller.SettingsManager
4141
detector detector.Detector
42-
imageCache expiringcache.Cache
42+
imageCache imagecacheutils.ImageCache
4343
stopSig concurrency.ErrorSignal
4444
}
4545

0 commit comments

Comments
 (0)