From 64eb710d0eac3b5f1fb29dcebd607beadc75c4aa Mon Sep 17 00:00:00 2001 From: varshaprasad96 Date: Thu, 7 Jan 2021 14:22:18 -0800 Subject: [PATCH] Deprecate InjectClient --- pkg/runtime/inject/inject.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/runtime/inject/inject.go b/pkg/runtime/inject/inject.go index 9af45b93f6..223d449a06 100644 --- a/pkg/runtime/inject/inject.go +++ b/pkg/runtime/inject/inject.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package inject has been deprecated, and will be removed in v0.10. package inject import ( @@ -24,8 +25,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + logf "sigs.k8s.io/controller-runtime/pkg/internal/log" ) +// logging is specifically to warn users about the deprecation of injectors. +var log = logf.RuntimeLog.WithName("injectors-warning") + // Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and // Reconciles type Cache interface { @@ -35,6 +40,7 @@ type Cache interface { // CacheInto will set informers on i and return the result if it implements Cache. Returns // false if i does not implement Cache. func CacheInto(c cache.Cache, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if s, ok := i.(Cache); ok { return true, s.InjectCache(c) } @@ -49,6 +55,7 @@ type APIReader interface { // APIReaderInto will set APIReader on i and return the result if it implements APIReaderInto. // Returns false if i does not implement APIReader func APIReaderInto(reader client.Reader, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if s, ok := i.(APIReader); ok { return true, s.InjectAPIReader(reader) } @@ -64,6 +71,7 @@ type Config interface { // ConfigInto will set config on i and return the result if it implements Config. Returns // false if i does not implement Config. func ConfigInto(config *rest.Config, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if s, ok := i.(Config); ok { return true, s.InjectConfig(config) } @@ -79,6 +87,7 @@ type Client interface { // ClientInto will set client on i and return the result if it implements Client. Returns // false if i does not implement Client. func ClientInto(client client.Client, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if s, ok := i.(Client); ok { return true, s.InjectClient(client) } @@ -94,6 +103,7 @@ type Scheme interface { // SchemeInto will set scheme and return the result on i if it implements Scheme. Returns // false if i does not implement Scheme. func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if is, ok := i.(Scheme); ok { return true, is.InjectScheme(scheme) } @@ -109,6 +119,7 @@ type Stoppable interface { // StopChannelInto will set stop channel on i and return the result if it implements Stoppable. // Returns false if i does not implement Stoppable. func StopChannelInto(stop <-chan struct{}, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if s, ok := i.(Stoppable); ok { return true, s.InjectStopChannel(stop) } @@ -123,6 +134,7 @@ type Mapper interface { // MapperInto will set the rest mapper on i and return the result if it implements Mapper. // Returns false if i does not implement Mapper. func MapperInto(mapper meta.RESTMapper, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if m, ok := i.(Mapper); ok { return true, m.InjectMapper(mapper) } @@ -140,6 +152,7 @@ type Injector interface { // InjectorInto will set f and return the result on i if it implements Injector. Returns // false if i does not implement Injector. func InjectorInto(f Func, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if ii, ok := i.(Injector); ok { return true, ii.InjectFunc(f) } @@ -155,6 +168,7 @@ type Logger interface { // LoggerInto will set the logger on the given object if it implements inject.Logger, // returning true if a InjectLogger was called, and false otherwise. func LoggerInto(l logr.Logger, i interface{}) (bool, error) { + log.Info("Injectors are deprecated, and will be removed in v0.10.x") if injectable, wantsLogger := i.(Logger); wantsLogger { return true, injectable.InjectLogger(l) }