diff --git a/go.mod b/go.mod index e2e9328a..5198171e 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,6 @@ require ( k8s.io/client-go v0.21.4 k8s.io/code-generator v0.21.4 k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 - knative.dev/hack v0.0.0-20211019034732-ced8ce706528 - knative.dev/pkg v0.0.0-20211019101734-caa95feec115 + knative.dev/hack v0.0.0-20211025203920-02860f59a556 + knative.dev/pkg v0.0.0-20211025151738-819d556cdaa5 ) diff --git a/go.sum b/go.sum index dfb3c1cc..459012b0 100644 --- a/go.sum +++ b/go.sum @@ -1084,11 +1084,11 @@ k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 h1:vEx13qjvaZ4yfObSSXW7Br k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/hack v0.0.0-20211018110626-47ac3b032e60/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/hack v0.0.0-20211019034732-ced8ce706528 h1:P3PuBxLnxESTnQL9Iv00wqFVL1a88MDj2zXDCQmvTvk= knative.dev/hack v0.0.0-20211019034732-ced8ce706528/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/pkg v0.0.0-20211019101734-caa95feec115 h1:rLX/wIB3FcitSin6QuW9r1QhsUcu+E3GHd99X9/0X+0= -knative.dev/pkg v0.0.0-20211019101734-caa95feec115/go.mod h1:FXppOkebhp8SBDFI0vVqmcwC98KBxodLheaVansP5r4= +knative.dev/hack v0.0.0-20211025203920-02860f59a556 h1:fO82ok0MvecmFmN1zGhCAw08uIiielhgN8NTdVVZEec= +knative.dev/hack v0.0.0-20211025203920-02860f59a556/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/pkg v0.0.0-20211025151738-819d556cdaa5 h1:CxOkd21mpg0SJ0NzvwbxhVL/yE7jw6JegEriOzFvgG8= +knative.dev/pkg v0.0.0-20211025151738-819d556cdaa5/go.mod h1:Q3PrYqZsnHU9rNJhyH/zhVdTojGfEqrkNnNG4arrJgE= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/pkg/client/injection/informers/caching/v1alpha1/image/image.go b/pkg/client/injection/informers/caching/v1alpha1/image/image.go index 4b143b1f..63e3b84d 100644 --- a/pkg/client/injection/informers/caching/v1alpha1/image/image.go +++ b/pkg/client/injection/informers/caching/v1alpha1/image/image.go @@ -50,7 +50,7 @@ func withInformer(ctx context.Context) (context.Context, controller.Informer) { } func withDynamicInformer(ctx context.Context) context.Context { - inf := &wrapper{client: client.Get(ctx)} + inf := &wrapper{client: client.Get(ctx), resourceVersion: injection.GetResourceVersion(ctx)} return context.WithValue(ctx, Key{}, inf) } @@ -68,6 +68,8 @@ type wrapper struct { client versioned.Interface namespace string + + resourceVersion string } var _ v1alpha1.ImageInformer = (*wrapper)(nil) @@ -82,13 +84,21 @@ func (w *wrapper) Lister() cachingv1alpha1.ImageLister { } func (w *wrapper) Images(namespace string) cachingv1alpha1.ImageNamespaceLister { - return &wrapper{client: w.client, namespace: namespace} + return &wrapper{client: w.client, namespace: namespace, resourceVersion: w.resourceVersion} +} + +// SetResourceVersion allows consumers to adjust the minimum resourceVersion +// used by the underlying client. It is not accessible via the standard +// lister interface, but can be accessed through a user-defined interface and +// an implementation check e.g. rvs, ok := foo.(ResourceVersionSetter) +func (w *wrapper) SetResourceVersion(resourceVersion string) { + w.resourceVersion = resourceVersion } func (w *wrapper) List(selector labels.Selector) (ret []*apiscachingv1alpha1.Image, err error) { lo, err := w.client.CachingV1alpha1().Images(w.namespace).List(context.TODO(), v1.ListOptions{ - LabelSelector: selector.String(), - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + LabelSelector: selector.String(), + ResourceVersion: w.resourceVersion, }) if err != nil { return nil, err @@ -101,6 +111,6 @@ func (w *wrapper) List(selector labels.Selector) (ret []*apiscachingv1alpha1.Ima func (w *wrapper) Get(name string) (*apiscachingv1alpha1.Image, error) { return w.client.CachingV1alpha1().Images(w.namespace).Get(context.TODO(), name, v1.GetOptions{ - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + ResourceVersion: w.resourceVersion, }) } diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/informer.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/informer.go index bbbffb4c..2138b85f 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/informer.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/informer.go @@ -143,6 +143,10 @@ func (g *injectionGenerator) GenerateType(c *generator.Context, t *types.Type, w Name: "NewSharedIndexInformer", }), "Namespaced": !tags.NonNamespaced, + "injectionGetResourceVersion": c.Universe.Function(types.Name{ + Package: "knative.dev/pkg/injection", + Name: "GetResourceVersion", + }), } sw.Do(injectionInformer, m) @@ -166,7 +170,7 @@ func withInformer(ctx {{.contextContext|raw}}) ({{.contextContext|raw}}, {{.cont } func withDynamicInformer(ctx {{.contextContext|raw}}) {{.contextContext|raw}} { - inf := &wrapper{client: {{ .clientGet|raw }}(ctx)} + inf := &wrapper{client: {{ .clientGet|raw }}(ctx), resourceVersion: {{ .injectionGetResourceVersion|raw }}(ctx)} return {{ .contextWithValue|raw }}(ctx, Key{}, inf) } @@ -185,6 +189,7 @@ type wrapper struct { {{ if .Namespaced }} namespace string {{ end }} + resourceVersion string } var _ {{.informersTypedInformer|raw}} = (*wrapper)(nil) @@ -200,14 +205,22 @@ func (w *wrapper) Lister() {{ .resourceLister|raw }} { {{if .Namespaced}} func (w *wrapper) {{ .type|publicPlural }}(namespace string) {{ .resourceNamespaceLister|raw }} { - return &wrapper{client: w.client, namespace: namespace} + return &wrapper{client: w.client, namespace: namespace, resourceVersion: w.resourceVersion} } {{end}} +// SetResourceVersion allows consumers to adjust the minimum resourceVersion +// used by the underlying client. It is not accessible via the standard +// lister interface, but can be accessed through a user-defined interface and +// an implementation check e.g. rvs, ok := foo.(ResourceVersionSetter) +func (w *wrapper) SetResourceVersion(resourceVersion string) { + w.resourceVersion = resourceVersion +} + func (w *wrapper) List(selector {{ .labelsSelector|raw }}) (ret []*{{ .type|raw }}, err error) { lo, err := w.client.{{.groupGoName}}{{.versionGoName}}().{{.type|publicPlural}}({{if .Namespaced}}w.namespace{{end}}).List({{ .contextTODO|raw }}(), {{ .metav1ListOptions|raw }}{ LabelSelector: selector.String(), - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + ResourceVersion: w.resourceVersion, }) if err != nil { return nil, err @@ -220,7 +233,7 @@ func (w *wrapper) List(selector {{ .labelsSelector|raw }}) (ret []*{{ .type|raw func (w *wrapper) Get(name string) (*{{ .type|raw }}, error) { return w.client.{{.groupGoName}}{{.versionGoName}}().{{.type|publicPlural}}({{if .Namespaced}}w.namespace{{end}}).Get({{ .contextTODO|raw }}(), name, {{ .metav1GetOptions|raw }}{ - // TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria. + ResourceVersion: w.resourceVersion, }) } diff --git a/vendor/knative.dev/pkg/injection/context.go b/vendor/knative.dev/pkg/injection/context.go index 4594ebeb..af8bf22a 100644 --- a/vendor/knative.dev/pkg/injection/context.go +++ b/vendor/knative.dev/pkg/injection/context.go @@ -66,3 +66,20 @@ func GetConfig(ctx context.Context) *rest.Config { } return value.(*rest.Config) } + +// rvKey is the key that the resource version is associated with. +type rvKey struct{} + +// WithResourceVersion associates a resource version with the context. +func WithResourceVersion(ctx context.Context, resourceVersion string) context.Context { + return context.WithValue(ctx, rvKey{}, resourceVersion) +} + +// GetResourceVersion gets the resource version associated with the context. +func GetResourceVersion(ctx context.Context) string { + value := ctx.Value(rvKey{}) + if value == nil { + return "" + } + return value.(string) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 531de2f2..dfc26094 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -610,10 +610,10 @@ k8s.io/kube-openapi/pkg/util/sets k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/hack v0.0.0-20211019034732-ced8ce706528 +# knative.dev/hack v0.0.0-20211025203920-02860f59a556 ## explicit knative.dev/hack -# knative.dev/pkg v0.0.0-20211019101734-caa95feec115 +# knative.dev/pkg v0.0.0-20211025151738-819d556cdaa5 ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck