Skip to content

Commit e95d55d

Browse files
authored
replace deprecated client injection (#605)
* replace deprecated client injection * remove unused error * fix tests
1 parent 8372997 commit e95d55d

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

cmd/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ func (m *Main) addToManager(r manager.Runnable) {
191191
if r, ok := r.(inject.Reader); ok {
192192
r.InjectReader(m.Manager.GetAPIReader())
193193
}
194+
if r, ok := r.(inject.Client); ok {
195+
r.InjectClient(m.Manager.GetClient())
196+
}
194197
if h, ok := r.(inject.Healthz); ok {
195198
if hc := h.HealthzCheck(); hc != nil {
196199
if err := m.Manager.AddHealthzCheck(h.Name(), hc); err != nil {

pkg/cron/cron.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ func (j *cronJob) InjectController(c lifecycle.Controller) {
4545
}
4646

4747
// InjectClient inject the client
48-
func (j *cronJob) InjectClient(c client.Client) error {
48+
func (j *cronJob) InjectClient(c client.Client) {
4949
j.client = c
50-
return nil
5150
}
5251

5352
// NeedLeaderElection may only start if leader is elected

pkg/cron/cron_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var _ = Describe("Cron", func() {
4949
cj = Job().(*cronJob)
5050
cj.InjectController(mockController)
5151
cj.InjectConfig(cfg)
52-
Ω(cj.InjectClient(mockClient)).ShouldNot(HaveOccurred())
52+
cj.InjectClient(mockClient)
5353
})
5454
Context("NeedLeaderElection", func() {
5555
It("should be true", func() {

pkg/inject/interfaces.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ type Reader interface {
2525
InjectReader(client.Reader)
2626
}
2727

28+
// Client inject the api client
29+
type Client interface {
30+
InjectClient(client.Client)
31+
}
32+
2833
// Config inject the config
2934
type Config interface {
3035
InjectConfig(*config.Config)

0 commit comments

Comments
 (0)