Skip to content

Commit

Permalink
fix closure variable in filtered factory
Browse files Browse the repository at this point in the history
  • Loading branch information
ReToCode authored and knative-prow-robot committed Nov 2, 2023
1 parent 29775d7 commit 8ae8120
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions codegen/cmd/injection-gen/generators/fake_filtered_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ func withInformerFactory(ctx {{.contextContext|raw}}) {{.contextContext|raw}} {
}
labelSelectors := untyped.([]string)
for _, selector := range labelSelectors {
selectorVal := selector
opts := []{{.informersSharedInformerOption|raw}}{}
if {{.injectionHasNamespace|raw}}(ctx) {
opts = append(opts, {{.informersWithNamespace|raw}}({{.injectionGetNamespace|raw}}(ctx)))
}
opts = append(opts, {{.informersWithTweakListOptions|raw}}(func(l *{{.metav1ListOptions|raw}}) {
l.LabelSelector = selector
l.LabelSelector = selectorVal
}))
ctx = context.WithValue(ctx, {{.factoryKey|raw}}{Selector: selector},
ctx = context.WithValue(ctx, {{.factoryKey|raw}}{Selector: selectorVal},
{{.informersNewSharedInformerFactoryWithOptions|raw}}(c, {{.controllerGetResyncPeriod|raw}}(ctx), opts...))
}
return ctx
Expand Down
5 changes: 3 additions & 2 deletions codegen/cmd/injection-gen/generators/filtered_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ func withInformerFactory(ctx {{.contextContext|raw}}) {{.contextContext|raw}} {
}
labelSelectors := untyped.([]string)
for _, selector := range labelSelectors {
selectorVal := selector
opts := []{{.informersSharedInformerOption|raw}}{}
if {{.injectionHasNamespace|raw}}(ctx) {
opts = append(opts, {{.informersWithNamespace|raw}}({{.injectionGetNamespace|raw}}(ctx)))
}
opts = append(opts, {{.informersWithTweakListOptions|raw}}(func(l *{{.metav1ListOptions|raw}}) {
l.LabelSelector = selector
l.LabelSelector = selectorVal
}))
ctx = context.WithValue(ctx, Key{Selector: selector},
ctx = context.WithValue(ctx, Key{Selector: selectorVal},
{{.informersNewSharedInformerFactoryWithOptions|raw}}(c, {{.controllerGetResyncPeriod|raw}}(ctx), opts...))
}
return ctx
Expand Down

0 comments on commit 8ae8120

Please sign in to comment.