Skip to content

Commit

Permalink
Drop several deprecated APIs. (#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor authored Aug 30, 2021
1 parent 2bd91f7 commit e957ee5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
13 changes: 0 additions & 13 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,6 @@ type ControllerOptions struct { //nolint // for backcompat.
Concurrency int
}

// NewImpl instantiates an instance of our controller that will feed work to the
// provided Reconciler as it is enqueued.
// Deprecated: use NewImplFull.
func NewImpl(r Reconciler, logger *zap.SugaredLogger, workQueueName string) *Impl {
return NewImplFull(r, ControllerOptions{WorkQueueName: workQueueName, Logger: logger})
}

// NewImplFull accepts the full set of options available to all controllers.
// Deprecated: use NewContext instead.
func NewImplFull(r Reconciler, options ControllerOptions) *Impl {
return NewContext(context.TODO(), r, options)
}

// NewContext instantiates an instance of our controller that will feed work to the
// provided Reconciler as it is enqueued.
func NewContext(ctx context.Context, r Reconciler, options ControllerOptions) *Impl {
Expand Down
22 changes: 11 additions & 11 deletions controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ func TestEnqueue(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var rl workqueue.RateLimiter = testRateLimiter{t, 100 * time.Millisecond}
impl := NewImplFull(&nopReconciler{}, ControllerOptions{WorkQueueName: "Testing", Logger: TestLogger(t), RateLimiter: rl})
impl := NewContext(context.TODO(), &nopReconciler{}, ControllerOptions{WorkQueueName: "Testing", Logger: TestLogger(t), RateLimiter: rl})
test.work(impl)

impl.WorkQueue().ShutDown()
Expand Down Expand Up @@ -751,7 +751,7 @@ func pollQ(q workqueue.RateLimitingInterface, sig chan int) func() (bool, error)
}

func TestEnqueueAfter(t *testing.T) {
impl := NewImplFull(&nopReconciler{}, ControllerOptions{
impl := NewContext(context.TODO(), &nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -818,7 +818,7 @@ func TestEnqueueAfter(t *testing.T) {
}

func TestEnqueueKeyAfter(t *testing.T) {
impl := NewImplFull(&nopReconciler{}, ControllerOptions{
impl := NewContext(context.TODO(), &nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -880,7 +880,7 @@ func (cr *CountingReconciler) Reconcile(context.Context, string) error {

func TestStartAndShutdown(t *testing.T) {
r := &CountingReconciler{}
impl := NewImplFull(&nopReconciler{}, ControllerOptions{
impl := NewContext(context.TODO(), &nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -950,7 +950,7 @@ func TestStartAndShutdownWithLeaderAwareNoElection(t *testing.T) {
},
},
}
impl := NewImplFull(r, ControllerOptions{
impl := NewContext(context.TODO(), r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -1022,7 +1022,7 @@ func TestStartAndShutdownWithLeaderAwareWithLostElection(t *testing.T) {
},
)

impl := NewImplFull(&nopReconciler{}, ControllerOptions{
impl := NewContext(context.TODO(), &nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -1066,7 +1066,7 @@ func TestStartAndShutdownWithLeaderAwareWithLostElection(t *testing.T) {
func TestStartAndShutdownWithWork(t *testing.T) {
r := &CountingReconciler{}
reporter := &FakeStatsReporter{}
impl := NewImplFull(r, ControllerOptions{
impl := NewContext(context.TODO(), r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
Expand Down Expand Up @@ -1170,7 +1170,7 @@ func TestStartAndShutdownWithErroringWork(t *testing.T) {

item := types.NamespacedName{Namespace: "", Name: "bar"}

impl := NewImplFull(&errorReconciler{}, ControllerOptions{
impl := NewContext(context.TODO(), &errorReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down Expand Up @@ -1229,7 +1229,7 @@ func (er *permanentErrorReconciler) Reconcile(context.Context, string) error {
func TestStartAndShutdownWithPermanentErroringWork(t *testing.T) {
r := &permanentErrorReconciler{}
reporter := &FakeStatsReporter{}
impl := NewImplFull(r, ControllerOptions{
impl := NewContext(context.TODO(), r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
Expand Down Expand Up @@ -1297,7 +1297,7 @@ func TestStartAndShutdownWithRequeuingWork(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
r := &requeueAfterReconciler{duration: test.duration}
reporter := &FakeStatsReporter{}
impl := NewImplFull(r, ControllerOptions{
impl := NewContext(context.TODO(), r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
Expand Down Expand Up @@ -1396,7 +1396,7 @@ func (*fakeStore) List() []interface{} {

func TestImplGlobalResync(t *testing.T) {
r := &CountingReconciler{}
impl := NewImplFull(r, ControllerOptions{
impl := NewContext(context.TODO(), r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
Expand Down
7 changes: 0 additions & 7 deletions resolver/addressable_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/cache"
"knative.dev/pkg/client/injection/ducks/duck/v1/addressable"
"knative.dev/pkg/controller"
Expand All @@ -49,12 +48,6 @@ type URIResolver struct {
resolvers []RefResolverFunc
}

// NewURIResolver constructs a new URIResolver with context, a tracker and an optional list of custom resolvers.
// Deprecated: use NewURIResolverFromTracker instead.
func NewURIResolver(ctx context.Context, callback func(types.NamespacedName), resolvers ...RefResolverFunc) *URIResolver {
return NewURIResolverFromTracker(ctx, tracker.New(callback, controller.GetTrackerLease(ctx)), resolvers...)
}

// NewURIResolverFromTracker constructs a new URIResolver with context, a tracker and an optional list of custom resolvers.
func NewURIResolverFromTracker(ctx context.Context, t tracker.Interface, resolvers ...RefResolverFunc) *URIResolver {
ret := &URIResolver{
Expand Down

0 comments on commit e957ee5

Please sign in to comment.