MCPcopy
hub / github.com/open-policy-agent/gatekeeper / NewCacheManager

Function NewCacheManager

pkg/cachemanager/cachemanager.go:90–128  ·  view source on GitHub ↗
(config *Config)

Source from the content-addressed store, hash-verified

88}
89
90func NewCacheManager(config *Config) (*CacheManager, error) {
91 if config.Registrar == nil {
92 return nil, fmt.Errorf("registrar must be non-nil")
93 }
94 if config.ProcessExcluder == nil {
95 return nil, fmt.Errorf("processExcluder must be non-nil")
96 }
97 if config.Tracker == nil {
98 return nil, fmt.Errorf("tracker must be non-nil")
99 }
100 if config.Reader == nil {
101 return nil, fmt.Errorf("reader must be non-nil")
102 }
103
104 if config.GVKAggregator == nil {
105 config.GVKAggregator = aggregator.NewGVKAggregator()
106 }
107
108 cfClient := config.CfClient
109 if cfClient == nil {
110 cfClient = &noopCFDataClient{}
111 }
112
113 cm := &CacheManager{
114 cfClient: cfClient,
115 syncMetricsCache: config.SyncMetricsCache,
116 tracker: config.Tracker,
117 processExcluder: config.ProcessExcluder,
118 registrar: config.Registrar,
119 watchedSet: watch.NewSet(),
120 reader: config.Reader,
121 gvksToSync: config.GVKAggregator,
122 backgroundManagementTicker: *time.NewTicker(3 * time.Second),
123 gvksToDeleteFromCache: watch.NewSet(),
124 danglingWatches: watch.NewSet(),
125 }
126
127 return cm, nil
128}
129
130func (c *CacheManager) Start(ctx context.Context) error {
131 go c.manageCache(ctx)

Callers 8

setupControllersFunction · 0.92
setupControllerFunction · 0.92
setupTestFunction · 0.92
TestReconcileFunction · 0.92
setupControllerFunction · 0.92
TestConfig_RetriesFunction · 0.92
makeTestResourcesFunction · 0.92
makeCacheManagerFunction · 0.85

Calls 2

NewGVKAggregatorFunction · 0.92
NewSetFunction · 0.92

Tested by 7

setupControllerFunction · 0.74
setupTestFunction · 0.74
TestReconcileFunction · 0.74
setupControllerFunction · 0.74
TestConfig_RetriesFunction · 0.74
makeTestResourcesFunction · 0.74
makeCacheManagerFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…