@@ -132,6 +132,7 @@ func (g *genericGenerator) GenerateType(c *generator.Context, t *types.Type, w i
132132 "cacheSharedIndexInformer" : c .Universe .Type (cacheSharedIndexInformer ),
133133 "scopeableCacheSharedIndexInformer" : c .Universe .Type (scopeableCacheSharedIndexInformer ),
134134 "fmtErrorf" : c .Universe .Type (fmtErrorfFunc ),
135+ "contextContext" : c .Universe .Type (contextContext ),
135136 "groups" : groups ,
136137 "schemeGVs" : schemeGVs ,
137138 "schemaGroupResource" : c .Universe .Type (schemaGroupResource ),
@@ -155,6 +156,7 @@ func (g *genericGenerator) GenerateType(c *generator.Context, t *types.Type, w i
155156var genericClusterInformer = `
156157type GenericClusterInformer interface {
157158 Cluster({{.logicalclusterName|raw}}) {{.genericInformer|raw}}
159+ ClusterWithContext({{.contextContext|raw}}, {{.logicalclusterName|raw}}) {{.genericInformer|raw}}
158160 Informer() {{.scopeableCacheSharedIndexInformer|raw}}
159161 Lister() {{.kcpcacheGenericClusterLister|raw}}
160162}
@@ -188,6 +190,15 @@ func (i *genericClusterInformer) Cluster(clusterName {{.logicalclusterName|raw}}
188190 lister: i.Lister().ByCluster(clusterName),
189191 }
190192}
193+
194+ // ClusterWithContext scopes to a GenericInformer and unregisters all
195+ // handles registered through it once the provided context is canceled.
196+ func (i *genericClusterInformer) ClusterWithContext(ctx {{.contextContext|raw}}, clusterName {{.logicalclusterName|raw}}) {{.genericInformer|raw}} {
197+ return &genericInformer{
198+ informer: i.Informer().ClusterWithContext(ctx, clusterName),
199+ lister: i.Lister().ByCluster(clusterName),
200+ }
201+ }
191202`
192203
193204var genericInformer = `
0 commit comments