Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ revert injection deprecation logging until internal injection code use stops #1382

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
type Cluster interface {
// SetFields will set any dependencies on an object for which the object has implemented the inject
// interface - e.g. inject.Client.
// Deprecated: use the equivalent Options field to set a field. This method will be removed in v0.10.
SetFields(interface{}) error

// GetConfig returns an initialized Config
Expand Down
1 change: 1 addition & 0 deletions pkg/internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Controller struct {
Queue workqueue.RateLimitingInterface

// SetFields is used to inject dependencies into other objects such as Sources, EventHandlers and Predicates
// Deprecated: the caller should handle injected fields itself.
SetFields func(i interface{}) error

// mu is used to synchronize Controller setup
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func (cm *controllerManager) Add(r Runnable) error {
return nil
}

// Deprecated: use the equivalent Options field to set a field. This method will be removed in v0.10.
func (cm *controllerManager) SetFields(i interface{}) error {
if _, err := inject.InjectorInto(cm.SetFields, i); err != nil {
return err
Expand Down
18 changes: 0 additions & 18 deletions pkg/runtime/inject/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,8 @@ import (

"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
)

// log is specifically to add a warning message for injectors.
var log = logf.RuntimeLog.WithName("injectors-warning")

// logWarningMsg logs a warning message if inject is used
func logWarningMsg() {
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
}

// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
// Reconciles
type Cache interface {
Expand All @@ -47,7 +38,6 @@ type Cache interface {
// false if i does not implement Cache.
func CacheInto(c cache.Cache, i interface{}) (bool, error) {
if s, ok := i.(Cache); ok {
logWarningMsg()
return true, s.InjectCache(c)
}
return false, nil
Expand All @@ -62,7 +52,6 @@ type APIReader interface {
// Returns false if i does not implement APIReader
func APIReaderInto(reader client.Reader, i interface{}) (bool, error) {
if s, ok := i.(APIReader); ok {
logWarningMsg()
return true, s.InjectAPIReader(reader)
}
return false, nil
Expand All @@ -78,7 +67,6 @@ type Config interface {
// false if i does not implement Config.
func ConfigInto(config *rest.Config, i interface{}) (bool, error) {
if s, ok := i.(Config); ok {
logWarningMsg()
return true, s.InjectConfig(config)
}
return false, nil
Expand All @@ -94,7 +82,6 @@ type Client interface {
// false if i does not implement Client.
func ClientInto(client client.Client, i interface{}) (bool, error) {
if s, ok := i.(Client); ok {
logWarningMsg()
return true, s.InjectClient(client)
}
return false, nil
Expand All @@ -110,7 +97,6 @@ type Scheme interface {
// false if i does not implement Scheme.
func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) {
if is, ok := i.(Scheme); ok {
logWarningMsg()
return true, is.InjectScheme(scheme)
}
return false, nil
Expand All @@ -126,7 +112,6 @@ type Stoppable interface {
// Returns false if i does not implement Stoppable.
func StopChannelInto(stop <-chan struct{}, i interface{}) (bool, error) {
if s, ok := i.(Stoppable); ok {
logWarningMsg()
return true, s.InjectStopChannel(stop)
}
return false, nil
Expand All @@ -141,7 +126,6 @@ type Mapper interface {
// Returns false if i does not implement Mapper.
func MapperInto(mapper meta.RESTMapper, i interface{}) (bool, error) {
if m, ok := i.(Mapper); ok {
logWarningMsg()
return true, m.InjectMapper(mapper)
}
return false, nil
Expand All @@ -159,7 +143,6 @@ type Injector interface {
// false if i does not implement Injector.
func InjectorInto(f Func, i interface{}) (bool, error) {
if ii, ok := i.(Injector); ok {
logWarningMsg()
return true, ii.InjectFunc(f)
}
return false, nil
Expand All @@ -175,7 +158,6 @@ type Logger interface {
// returning true if a InjectLogger was called, and false otherwise.
func LoggerInto(l logr.Logger, i interface{}) (bool, error) {
if injectable, wantsLogger := i.(Logger); wantsLogger {
logWarningMsg()
return true, injectable.InjectLogger(l)
}
return false, nil
Expand Down