Skip to content

Commit ae59b64

Browse files
Deprecate InjectClient
1 parent 66537ca commit ae59b64

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/runtime/inject/inject.go

Lines changed: 13 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,11 @@ 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+
var log = logf.RuntimeLog.WithName("inject-interface-warning")
32+
2933
// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
3034
// Reconciles
3135
type Cache interface {
@@ -35,6 +39,7 @@ type Cache interface {
3539
// CacheInto will set informers on i and return the result if it implements Cache. Returns
3640
// false if i does not implement Cache.
3741
func CacheInto(c cache.Cache, i interface{}) (bool, error) {
42+
log.Info("Injectors are deprecated, and will be removed in v0.10")
3843
if s, ok := i.(Cache); ok {
3944
return true, s.InjectCache(c)
4045
}
@@ -49,6 +54,7 @@ type APIReader interface {
4954
// APIReaderInto will set APIReader on i and return the result if it implements APIReaderInto.
5055
// Returns false if i does not implement APIReader
5156
func APIReaderInto(reader client.Reader, i interface{}) (bool, error) {
57+
log.Info("Injectors are deprecated, and will be removed in v0.10")
5258
if s, ok := i.(APIReader); ok {
5359
return true, s.InjectAPIReader(reader)
5460
}
@@ -64,6 +70,7 @@ type Config interface {
6470
// ConfigInto will set config on i and return the result if it implements Config. Returns
6571
// false if i does not implement Config.
6672
func ConfigInto(config *rest.Config, i interface{}) (bool, error) {
73+
log.Info("Injectors are deprecated, and will be removed in v0.10")
6774
if s, ok := i.(Config); ok {
6875
return true, s.InjectConfig(config)
6976
}
@@ -79,6 +86,7 @@ type Client interface {
7986
// ClientInto will set client on i and return the result if it implements Client. Returns
8087
// false if i does not implement Client.
8188
func ClientInto(client client.Client, i interface{}) (bool, error) {
89+
log.Info("Injectors are deprecated, and will be removed in v0.10")
8290
if s, ok := i.(Client); ok {
8391
return true, s.InjectClient(client)
8492
}
@@ -94,6 +102,7 @@ type Scheme interface {
94102
// SchemeInto will set scheme and return the result on i if it implements Scheme. Returns
95103
// false if i does not implement Scheme.
96104
func SchemeInto(scheme *runtime.Scheme, i interface{}) (bool, error) {
105+
log.Info("Injectors are deprecated, and will be removed in v0.10")
97106
if is, ok := i.(Scheme); ok {
98107
return true, is.InjectScheme(scheme)
99108
}
@@ -109,6 +118,7 @@ type Stoppable interface {
109118
// StopChannelInto will set stop channel on i and return the result if it implements Stoppable.
110119
// Returns false if i does not implement Stoppable.
111120
func StopChannelInto(stop <-chan struct{}, i interface{}) (bool, error) {
121+
log.Info("Injectors are deprecated, and will be removed in v0.10")
112122
if s, ok := i.(Stoppable); ok {
113123
return true, s.InjectStopChannel(stop)
114124
}
@@ -123,6 +133,7 @@ type Mapper interface {
123133
// MapperInto will set the rest mapper on i and return the result if it implements Mapper.
124134
// Returns false if i does not implement Mapper.
125135
func MapperInto(mapper meta.RESTMapper, i interface{}) (bool, error) {
136+
log.Info("Injectors are deprecated, and will be removed in v0.10")
126137
if m, ok := i.(Mapper); ok {
127138
return true, m.InjectMapper(mapper)
128139
}
@@ -140,6 +151,7 @@ type Injector interface {
140151
// InjectorInto will set f and return the result on i if it implements Injector. Returns
141152
// false if i does not implement Injector.
142153
func InjectorInto(f Func, i interface{}) (bool, error) {
154+
log.Info("Injectors are deprecated, and will be removed in v0.10")
143155
if ii, ok := i.(Injector); ok {
144156
return true, ii.InjectFunc(f)
145157
}
@@ -155,6 +167,7 @@ type Logger interface {
155167
// LoggerInto will set the logger on the given object if it implements inject.Logger,
156168
// returning true if a InjectLogger was called, and false otherwise.
157169
func LoggerInto(l logr.Logger, i interface{}) (bool, error) {
170+
log.Info("Injectors are deprecated, and will be removed in v0.10")
158171
if injectable, wantsLogger := i.(Logger); wantsLogger {
159172
return true, injectable.InjectLogger(l)
160173
}

0 commit comments

Comments
 (0)