@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ // Package inject is used by a Manager to inject types into Sources, EventHandlers, Predicates, and Reconciles.
18+ // Deprecated: Use manager.Options fields directly. This package will be removed in v0.10.
1719package inject
1820
1921import (
@@ -24,8 +26,17 @@ import (
2426
2527 "sigs.k8s.io/controller-runtime/pkg/cache"
2628 "sigs.k8s.io/controller-runtime/pkg/client"
29+ logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
2730)
2831
32+ // log is specifically to add a warning message for injectors.
33+ var log = logf .RuntimeLog .WithName ("injectors-warning" )
34+
35+ // logWarningMsg logs a warning message if inject is used
36+ func logWarningMsg () {
37+ log .Info ("Injectors are deprecated, and will be removed in v0.10.x" )
38+ }
39+
2940// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
3041// Reconciles
3142type Cache interface {
@@ -36,6 +47,7 @@ type Cache interface {
3647// false if i does not implement Cache.
3748func CacheInto (c cache.Cache , i interface {}) (bool , error ) {
3849 if s , ok := i .(Cache ); ok {
50+ logWarningMsg ()
3951 return true , s .InjectCache (c )
4052 }
4153 return false , nil
@@ -50,6 +62,7 @@ type APIReader interface {
5062// Returns false if i does not implement APIReader
5163func APIReaderInto (reader client.Reader , i interface {}) (bool , error ) {
5264 if s , ok := i .(APIReader ); ok {
65+ logWarningMsg ()
5366 return true , s .InjectAPIReader (reader )
5467 }
5568 return false , nil
@@ -65,6 +78,7 @@ type Config interface {
6578// false if i does not implement Config.
6679func ConfigInto (config * rest.Config , i interface {}) (bool , error ) {
6780 if s , ok := i .(Config ); ok {
81+ logWarningMsg ()
6882 return true , s .InjectConfig (config )
6983 }
7084 return false , nil
@@ -80,6 +94,7 @@ type Client interface {
8094// false if i does not implement Client.
8195func ClientInto (client client.Client , i interface {}) (bool , error ) {
8296 if s , ok := i .(Client ); ok {
97+ logWarningMsg ()
8398 return true , s .InjectClient (client )
8499 }
85100 return false , nil
@@ -95,6 +110,7 @@ type Scheme interface {
95110// false if i does not implement Scheme.
96111func SchemeInto (scheme * runtime.Scheme , i interface {}) (bool , error ) {
97112 if is , ok := i .(Scheme ); ok {
113+ logWarningMsg ()
98114 return true , is .InjectScheme (scheme )
99115 }
100116 return false , nil
@@ -110,6 +126,7 @@ type Stoppable interface {
110126// Returns false if i does not implement Stoppable.
111127func StopChannelInto (stop <- chan struct {}, i interface {}) (bool , error ) {
112128 if s , ok := i .(Stoppable ); ok {
129+ logWarningMsg ()
113130 return true , s .InjectStopChannel (stop )
114131 }
115132 return false , nil
@@ -124,6 +141,7 @@ type Mapper interface {
124141// Returns false if i does not implement Mapper.
125142func MapperInto (mapper meta.RESTMapper , i interface {}) (bool , error ) {
126143 if m , ok := i .(Mapper ); ok {
144+ logWarningMsg ()
127145 return true , m .InjectMapper (mapper )
128146 }
129147 return false , nil
@@ -141,6 +159,7 @@ type Injector interface {
141159// false if i does not implement Injector.
142160func InjectorInto (f Func , i interface {}) (bool , error ) {
143161 if ii , ok := i .(Injector ); ok {
162+ logWarningMsg ()
144163 return true , ii .InjectFunc (f )
145164 }
146165 return false , nil
@@ -156,6 +175,7 @@ type Logger interface {
156175// returning true if a InjectLogger was called, and false otherwise.
157176func LoggerInto (l logr.Logger , i interface {}) (bool , error ) {
158177 if injectable , wantsLogger := i .(Logger ); wantsLogger {
178+ logWarningMsg ()
159179 return true , injectable .InjectLogger (l )
160180 }
161181 return false , nil
0 commit comments