Skip to content

Commit 4161b01

Browse files
committed
Remove deprecated funcs & fields
1 parent 52ce239 commit 4161b01

File tree

8 files changed

+19
-73
lines changed

8 files changed

+19
-73
lines changed

pkg/cache/cache_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ var _ = Describe("Informer Cache", func() {
118118
CacheTest(cache.New, cache.Options{})
119119
})
120120
var _ = Describe("Multi-Namespace Informer Cache", func() {
121-
CacheTest(cache.MultiNamespacedCacheBuilder([]string{testNamespaceOne, testNamespaceTwo, "default"}), cache.Options{})
121+
CacheTest(cache.New, cache.Options{
122+
Namespaces: []string{testNamespaceOne, testNamespaceTwo, "default"},
123+
})
122124
})
123125

124126
var _ = Describe("Informer Cache without global DeepCopy", func() {
@@ -931,8 +933,9 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
931933
})
932934
It("test multinamespaced cache for cluster scoped resources", func() {
933935
By("creating a multinamespaced cache to watch specific namespaces")
934-
multi := cache.MultiNamespacedCacheBuilder([]string{"default", testNamespaceOne})
935-
m, err := multi(cfg, cache.Options{})
936+
m, err := cache.New(cfg, cache.Options{
937+
Namespaces: []string{"default", testNamespaceOne},
938+
})
936939
Expect(err).NotTo(HaveOccurred())
937940

938941
By("running the cache and waiting it for sync")

pkg/cache/multi_namespace_cache.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ import (
3535
// a new global namespaced cache to handle cluster scoped resources.
3636
const globalCache = "_cluster-scope"
3737

38-
// MultiNamespacedCacheBuilder - Builder function to create a new multi-namespaced cache.
39-
// This will scope the cache to a list of namespaces. Listing for all namespaces
40-
// will list for all the namespaces that this knows about. By default, this will create
41-
// a global cache for cluster scoped resource. Note that this is not intended
42-
// to be used for excluding namespaces, this is better done via a Predicate. Also note that
43-
// you may face performance issues when using this with a high number of namespaces.
44-
//
45-
// Deprecated: Use cache.Options.Namespaces instead.
46-
func MultiNamespacedCacheBuilder(namespaces []string) NewCacheFunc {
47-
return func(config *rest.Config, opts Options) (Cache, error) {
48-
opts.Namespaces = namespaces
49-
return newMultiNamespaceCache(config, opts)
50-
}
51-
}
52-
5338
func newMultiNamespaceCache(config *rest.Config, opts Options) (Cache, error) {
5439
if len(opts.Namespaces) < 2 {
5540
return nil, fmt.Errorf("must specify more than one namespace to use multi-namespace cache")

pkg/client/fake/client.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import (
3131

3232
// Using v4 to match upstream
3333
jsonpatch "github.com/evanphx/json-patch"
34-
"sigs.k8s.io/controller-runtime/pkg/client/interceptor"
35-
3634
corev1 "k8s.io/api/core/v1"
3735
policyv1 "k8s.io/api/policy/v1"
3836
policyv1beta1 "k8s.io/api/policy/v1beta1"
@@ -52,10 +50,11 @@ import (
5250
"k8s.io/apimachinery/pkg/watch"
5351
"k8s.io/client-go/kubernetes/scheme"
5452
"k8s.io/client-go/testing"
55-
"sigs.k8s.io/controller-runtime/pkg/internal/field/selector"
5653

5754
"sigs.k8s.io/controller-runtime/pkg/client"
5855
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
56+
"sigs.k8s.io/controller-runtime/pkg/client/interceptor"
57+
"sigs.k8s.io/controller-runtime/pkg/internal/field/selector"
5958
"sigs.k8s.io/controller-runtime/pkg/internal/objectutil"
6059
)
6160

@@ -88,21 +87,10 @@ const (
8887

8988
// NewFakeClient creates a new fake client for testing.
9089
// You can choose to initialize it with a slice of runtime.Object.
91-
//
92-
// Deprecated: Please use NewClientBuilder instead.
9390
func NewFakeClient(initObjs ...runtime.Object) client.WithWatch {
9491
return NewClientBuilder().WithRuntimeObjects(initObjs...).Build()
9592
}
9693

97-
// NewFakeClientWithScheme creates a new fake client with the given scheme
98-
// for testing.
99-
// You can choose to initialize it with a slice of runtime.Object.
100-
//
101-
// Deprecated: Please use NewClientBuilder instead.
102-
func NewFakeClientWithScheme(clientScheme *runtime.Scheme, initObjs ...runtime.Object) client.WithWatch {
103-
return NewClientBuilder().WithScheme(clientScheme).WithRuntimeObjects(initObjs...).Build()
104-
}
105-
10694
// NewClientBuilder returns a new builder to create a fake client.
10795
func NewClientBuilder() *ClientBuilder {
10896
return &ClientBuilder{}

pkg/client/fake/client_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,26 @@ import (
2323
"strconv"
2424
"time"
2525

26-
"sigs.k8s.io/controller-runtime/pkg/client/interceptor"
27-
2826
"github.com/google/go-cmp/cmp"
2927
. "github.com/onsi/ginkgo/v2"
3028
. "github.com/onsi/gomega"
31-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
32-
"k8s.io/apimachinery/pkg/fields"
33-
"k8s.io/apimachinery/pkg/labels"
34-
"k8s.io/client-go/kubernetes/fake"
35-
3629
appsv1 "k8s.io/api/apps/v1"
3730
coordinationv1 "k8s.io/api/coordination/v1"
3831
corev1 "k8s.io/api/core/v1"
3932
policyv1 "k8s.io/api/policy/v1"
4033
policyv1beta1 "k8s.io/api/policy/v1beta1"
4134
apierrors "k8s.io/apimachinery/pkg/api/errors"
4235
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
36+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
37+
"k8s.io/apimachinery/pkg/fields"
38+
"k8s.io/apimachinery/pkg/labels"
4339
"k8s.io/apimachinery/pkg/runtime"
4440
"k8s.io/apimachinery/pkg/types"
4541
"k8s.io/apimachinery/pkg/watch"
42+
"k8s.io/client-go/kubernetes/fake"
43+
4644
"sigs.k8s.io/controller-runtime/pkg/client"
45+
"sigs.k8s.io/controller-runtime/pkg/client/interceptor"
4746
)
4847

4948
var _ = Describe("Fake client", func() {
@@ -180,7 +179,7 @@ var _ = Describe("Fake client", func() {
180179
}
181180

182181
By("Adding the object during client initialization")
183-
cl = NewFakeClient(unstructuredEndpoint())
182+
cl = NewClientBuilder().WithRuntimeObjects(unstructuredEndpoint()).Build()
184183
list()
185184
Expect(cl.Delete(context.Background(), unstructuredEndpoint())).To(Succeed())
186185

pkg/controller/controllerutil/controllerutil.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"k8s.io/apimachinery/pkg/runtime"
2929
"k8s.io/apimachinery/pkg/runtime/schema"
3030
"k8s.io/utils/pointer"
31+
3132
"sigs.k8s.io/controller-runtime/pkg/client"
3233
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
3334
)
@@ -389,9 +390,3 @@ func ContainsFinalizer(o client.Object, finalizer string) bool {
389390
}
390391
return false
391392
}
392-
393-
// Object allows functions to work indistinctly with any resource that
394-
// implements both Object interfaces.
395-
//
396-
// Deprecated: Use client.Object instead.
397-
type Object = client.Object

pkg/envtest/server.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ type Environment struct {
161161
// environment variable or 20 seconds if unspecified
162162
ControlPlaneStopTimeout time.Duration
163163

164-
// KubeAPIServerFlags is the set of flags passed while starting the api server.
165-
//
166-
// Deprecated: use ControlPlane.GetAPIServer().Configure() instead.
167-
KubeAPIServerFlags []string
168-
169164
// AttachControlPlaneOutput indicates if control plane output will be attached to os.Stdout and os.Stderr.
170165
// Enable this to get more visibility of the testing control plane.
171166
// It respect KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT environment variable.
@@ -210,19 +205,7 @@ func (te *Environment) Start() (*rest.Config, error) {
210205
}
211206
} else {
212207
apiServer := te.ControlPlane.GetAPIServer()
213-
if len(apiServer.Args) == 0 { //nolint:staticcheck
214-
// pass these through separately from above in case something like
215-
// AddUser defaults APIServer.
216-
//
217-
// TODO(directxman12): if/when we feel like making a bigger
218-
// breaking change here, just make APIServer and Etcd non-pointers
219-
// in ControlPlane.
220-
221-
// NB(directxman12): we still pass these in so that things work if the
222-
// user manually specifies them, but in most cases we expect them to
223-
// be nil so that we use the new .Configure() logic.
224-
apiServer.Args = te.KubeAPIServerFlags //nolint:staticcheck
225-
}
208+
226209
if te.ControlPlane.Etcd == nil {
227210
te.ControlPlane.Etcd = &controlplane.Etcd{}
228211
}

pkg/envtest/webhook_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
corev1 "k8s.io/api/core/v1"
3030
apierrors "k8s.io/apimachinery/pkg/api/errors"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32+
3233
"sigs.k8s.io/controller-runtime/pkg/client"
3334
"sigs.k8s.io/controller-runtime/pkg/manager"
3435
"sigs.k8s.io/controller-runtime/pkg/webhook"

pkg/log/zap/zap.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ type Options struct {
148148
// DestWriter controls the destination of the log output. Defaults to
149149
// os.Stderr.
150150
DestWriter io.Writer
151-
// DestWritter controls the destination of the log output. Defaults to
152-
// os.Stderr.
153-
//
154-
// Deprecated: Use DestWriter instead
155-
DestWritter io.Writer
156151
// Level configures the verbosity of the logging.
157152
// Defaults to Debug when Development is true and Info otherwise.
158153
// A zap log level should be multiplied by -1 to get the logr verbosity.
@@ -174,11 +169,8 @@ type Options struct {
174169

175170
// addDefaults adds defaults to the Options.
176171
func (o *Options) addDefaults() {
177-
if o.DestWriter == nil && o.DestWritter == nil {
172+
if o.DestWriter == nil {
178173
o.DestWriter = os.Stderr
179-
} else if o.DestWriter == nil && o.DestWritter != nil {
180-
// while misspelled DestWritter is deprecated but still not removed
181-
o.DestWriter = o.DestWritter
182174
}
183175

184176
if o.Development {

0 commit comments

Comments
 (0)