Skip to content

Commit 92e5147

Browse files
Deprecate InjectClient
1 parent 66537ca commit 92e5147

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/runtime/inject/inject.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Deprecated: Injectors are deprecated, and will be removed in v0.10.
1718
package inject
1819

1920
import (
@@ -24,8 +25,12 @@ import (
2425

2526
"sigs.k8s.io/controller-runtime/pkg/cache"
2627
"sigs.k8s.io/controller-runtime/pkg/client"
28+
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
2729
)
2830

31+
// logging is specifically to warn users about the deprecation of injectors.
32+
var log = logf.RuntimeLog.WithName("injectors-warning")
33+
2934
// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
3035
// Reconciles
3136
type Cache interface {
@@ -35,6 +40,7 @@ type Cache interface {
3540
// CacheInto will set informers on i and return the result if it implements Cache. Returns
3641
// false if i does not implement Cache.
3742
func CacheInto(c cache.Cache, i interface{}) (bool, error) {
43+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
3844
if s, ok := i.(Cache); ok {
3945
return true, s.InjectCache(c)
4046
}
@@ -49,6 +55,7 @@ type APIReader interface {
4955
// APIReaderInto will set APIReader on i and return the result if it implements APIReaderInto.
5056
// Returns false if i does not implement APIReader
5157
func APIReaderInto(reader client.Reader, i interface{}) (bool, error) {
58+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
5259
if s, ok := i.(APIReader); ok {
5360
return true, s.InjectAPIReader(reader)
5461
}
@@ -64,6 +71,7 @@ type Config interface {
6471
// ConfigInto will set config on i and return the result if it implements Config. Returns
6572
// false if i does not implement Config.
6673
func ConfigInto(config *rest.Config, i interface{}) (bool, error) {
74+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
6775
if s, ok := i.(Config); ok {
6876
return true, s.InjectConfig(config)
6977
}
@@ -79,6 +87,7 @@ type Client interface {
7987
// ClientInto will set client on i and return the result if it implements Client. Returns
8088
// false if i does not implement Client.
8189
func ClientInto(client client.Client, i interface{}) (bool, error) {
90+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
8291
if s, ok := i.(Client); ok {
8392
return true, s.InjectClient(client)
8493
}
@@ -94,6 +103,7 @@ type Scheme interface {
94103
// SchemeInto will set scheme and return the result on i if it implements Scheme. Returns
95104
// false if i does not implement Scheme.
96105
func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) {
106+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
97107
if is, ok := i.(Scheme); ok {
98108
return true, is.InjectScheme(scheme)
99109
}
@@ -109,6 +119,7 @@ type Stoppable interface {
109119
// StopChannelInto will set stop channel on i and return the result if it implements Stoppable.
110120
// Returns false if i does not implement Stoppable.
111121
func StopChannelInto(stop <-chan struct{}, i interface{}) (bool, error) {
122+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
112123
if s, ok := i.(Stoppable); ok {
113124
return true, s.InjectStopChannel(stop)
114125
}
@@ -123,6 +134,7 @@ type Mapper interface {
123134
// MapperInto will set the rest mapper on i and return the result if it implements Mapper.
124135
// Returns false if i does not implement Mapper.
125136
func MapperInto(mapper meta.RESTMapper, i interface{}) (bool, error) {
137+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
126138
if m, ok := i.(Mapper); ok {
127139
return true, m.InjectMapper(mapper)
128140
}
@@ -140,6 +152,7 @@ type Injector interface {
140152
// InjectorInto will set f and return the result on i if it implements Injector. Returns
141153
// false if i does not implement Injector.
142154
func InjectorInto(f Func, i interface{}) (bool, error) {
155+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
143156
if ii, ok := i.(Injector); ok {
144157
return true, ii.InjectFunc(f)
145158
}
@@ -155,6 +168,7 @@ type Logger interface {
155168
// LoggerInto will set the logger on the given object if it implements inject.Logger,
156169
// returning true if a InjectLogger was called, and false otherwise.
157170
func LoggerInto(l logr.Logger, i interface{}) (bool, error) {
171+
log.Info("Injectors are deprecated, and will be removed in v0.10.x")
158172
if injectable, wantsLogger := i.(Logger); wantsLogger {
159173
return true, injectable.InjectLogger(l)
160174
}

0 commit comments

Comments
 (0)