@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
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.
17
19
package inject
18
20
19
21
import (
@@ -24,8 +26,17 @@ import (
24
26
25
27
"sigs.k8s.io/controller-runtime/pkg/cache"
26
28
"sigs.k8s.io/controller-runtime/pkg/client"
29
+ logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
27
30
)
28
31
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
+
29
40
// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
30
41
// Reconciles
31
42
type Cache interface {
@@ -36,6 +47,7 @@ type Cache interface {
36
47
// false if i does not implement Cache.
37
48
func CacheInto (c cache.Cache , i interface {}) (bool , error ) {
38
49
if s , ok := i .(Cache ); ok {
50
+ logWarningMsg ()
39
51
return true , s .InjectCache (c )
40
52
}
41
53
return false , nil
@@ -50,6 +62,7 @@ type APIReader interface {
50
62
// Returns false if i does not implement APIReader
51
63
func APIReaderInto (reader client.Reader , i interface {}) (bool , error ) {
52
64
if s , ok := i .(APIReader ); ok {
65
+ logWarningMsg ()
53
66
return true , s .InjectAPIReader (reader )
54
67
}
55
68
return false , nil
@@ -65,6 +78,7 @@ type Config interface {
65
78
// false if i does not implement Config.
66
79
func ConfigInto (config * rest.Config , i interface {}) (bool , error ) {
67
80
if s , ok := i .(Config ); ok {
81
+ logWarningMsg ()
68
82
return true , s .InjectConfig (config )
69
83
}
70
84
return false , nil
@@ -80,6 +94,7 @@ type Client interface {
80
94
// false if i does not implement Client.
81
95
func ClientInto (client client.Client , i interface {}) (bool , error ) {
82
96
if s , ok := i .(Client ); ok {
97
+ logWarningMsg ()
83
98
return true , s .InjectClient (client )
84
99
}
85
100
return false , nil
@@ -95,6 +110,7 @@ type Scheme interface {
95
110
// false if i does not implement Scheme.
96
111
func SchemeInto (scheme * runtime.Scheme , i interface {}) (bool , error ) {
97
112
if is , ok := i .(Scheme ); ok {
113
+ logWarningMsg ()
98
114
return true , is .InjectScheme (scheme )
99
115
}
100
116
return false , nil
@@ -110,6 +126,7 @@ type Stoppable interface {
110
126
// Returns false if i does not implement Stoppable.
111
127
func StopChannelInto (stop <- chan struct {}, i interface {}) (bool , error ) {
112
128
if s , ok := i .(Stoppable ); ok {
129
+ logWarningMsg ()
113
130
return true , s .InjectStopChannel (stop )
114
131
}
115
132
return false , nil
@@ -124,6 +141,7 @@ type Mapper interface {
124
141
// Returns false if i does not implement Mapper.
125
142
func MapperInto (mapper meta.RESTMapper , i interface {}) (bool , error ) {
126
143
if m , ok := i .(Mapper ); ok {
144
+ logWarningMsg ()
127
145
return true , m .InjectMapper (mapper )
128
146
}
129
147
return false , nil
@@ -141,6 +159,7 @@ type Injector interface {
141
159
// false if i does not implement Injector.
142
160
func InjectorInto (f Func , i interface {}) (bool , error ) {
143
161
if ii , ok := i .(Injector ); ok {
162
+ logWarningMsg ()
144
163
return true , ii .InjectFunc (f )
145
164
}
146
165
return false , nil
@@ -156,6 +175,7 @@ type Logger interface {
156
175
// returning true if a InjectLogger was called, and false otherwise.
157
176
func LoggerInto (l logr.Logger , i interface {}) (bool , error ) {
158
177
if injectable , wantsLogger := i .(Logger ); wantsLogger {
178
+ logWarningMsg ()
159
179
return true , injectable .InjectLogger (l )
160
180
}
161
181
return false , nil
0 commit comments