From ae59b64b0a313228dc443ea4d89e9763ad404b50 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/runtime/inject/inject.go b/pkg/runtime/inject/inject.go index 9af45b93f6..e92f45af72 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. */ +// Deprecated: Injectors are deprecated, and will be removed in v0.10. package inject import ( @@ -24,8 +25,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + logf "sigs.k8s.io/controller-runtime/pkg/internal/log" ) +var log = logf.RuntimeLog.WithName("inject-interface-warning") + // Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and // Reconciles type Cache interface { @@ -35,6 +39,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") if s, ok := i.(Cache); ok { return true, s.InjectCache(c) } @@ -49,6 +54,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") if s, ok := i.(APIReader); ok { return true, s.InjectAPIReader(reader) } @@ -64,6 +70,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") if s, ok := i.(Config); ok { return true, s.InjectConfig(config) } @@ -79,6 +86,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") if s, ok := i.(Client); ok { return true, s.InjectClient(client) } @@ -94,6 +102,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") if is, ok := i.(Scheme); ok { return true, is.InjectScheme(scheme) } @@ -109,6 +118,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") if s, ok := i.(Stoppable); ok { return true, s.InjectStopChannel(stop) } @@ -123,6 +133,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") if m, ok := i.(Mapper); ok { return true, m.InjectMapper(mapper) } @@ -140,6 +151,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") if ii, ok := i.(Injector); ok { return true, ii.InjectFunc(f) } @@ -155,6 +167,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") if injectable, wantsLogger := i.(Logger); wantsLogger { return true, injectable.InjectLogger(l) }