Skip to content

Commit

Permalink
Deprecate InjectClient
Browse files Browse the repository at this point in the history
  • Loading branch information
varshaprasad96 committed Jan 8, 2021
1 parent 66537ca commit 92e5147
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/runtime/inject/inject.go
Expand Up @@ -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 (
Expand All @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 92e5147

Please sign in to comment.