-
Notifications
You must be signed in to change notification settings - Fork 0
/
ocimetricssource.go
49 lines (42 loc) · 1.59 KB
/
ocimetricssource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Code generated by injection-gen. DO NOT EDIT.
package filtered
import (
context "context"
v1alpha1 "github.com/zeiss/typhoon/pkg/client/generated/informers/externalversions/sources/v1alpha1"
filtered "github.com/zeiss/typhoon/pkg/client/generated/injection/informers/factory/filtered"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
logging "knative.dev/pkg/logging"
)
func init() {
injection.Default.RegisterFilteredInformers(withInformer)
}
// Key is used for associating the Informer inside the context.Context.
type Key struct {
Selector string
}
func withInformer(ctx context.Context) (context.Context, []controller.Informer) {
untyped := ctx.Value(filtered.LabelKey{})
if untyped == nil {
logging.FromContext(ctx).Panic(
"Unable to fetch labelkey from context.")
}
labelSelectors := untyped.([]string)
infs := []controller.Informer{}
for _, selector := range labelSelectors {
f := filtered.Get(ctx, selector)
inf := f.Sources().V1alpha1().OCIMetricsSources()
ctx = context.WithValue(ctx, Key{Selector: selector}, inf)
infs = append(infs, inf.Informer())
}
return ctx, infs
}
// Get extracts the typed informer from the context.
func Get(ctx context.Context, selector string) v1alpha1.OCIMetricsSourceInformer {
untyped := ctx.Value(Key{Selector: selector})
if untyped == nil {
logging.FromContext(ctx).Panicf(
"Unable to fetch github.com/zeiss/typhoon/pkg/client/generated/informers/externalversions/sources/v1alpha1.OCIMetricsSourceInformer with selector %s from context.", selector)
}
return untyped.(v1alpha1.OCIMetricsSourceInformer)
}