mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-02-15 00:07:52 +08:00
fake client-go: un-deprecate NewSimpleClientset
NewSimpleClientset was marked as deprecated when NewClientset was introduced. This has caused some confusion: - Not all packages have NewClientset (https://github.com/kubernetes/kubernetes/issues/135980). - Tests that work with NewSimpleClientset fail when switched to NewClientset (https://github.com/kubernetes/kubernetes/issues/136327) because of missing CRD support (https://github.com/kubernetes/kubernetes/issues/126850). It doesn't seem burdensome to keep NewSimpleClientset around forever. Some unit tests may even prefer to use it when they don't need server-side apply (less overhead). Therefore there is no need to deprecate it. This avoids churn in the eco system because contributors no longer create PRs "because the linter complains about the usage of a deprecated function". Kubernetes-commit: e80da21868059f789c90105a00481fa8cef169e1
This commit is contained in:
committed by
Kubernetes Publisher
parent
c59724d92f
commit
2ee58e6c15
@@ -35,10 +35,6 @@ import (
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
//
|
||||
// Deprecated: NewClientset replaces this with support for field management, which significantly improves
|
||||
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
|
||||
// via --with-applyconfig).
|
||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
@@ -99,6 +95,10 @@ func (c *Clientset) IsWatchListSemanticsUnSupported() bool {
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
//
|
||||
// Compared to NewSimpleClientset, the Clientset returned here supports field tracking and thus
|
||||
// server-side apply. Beware though that support in that for CRDs is missing
|
||||
// (https://github.com/kubernetes/kubernetes/issues/126850).
|
||||
func NewClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewFieldManagedObjectTracker(
|
||||
scheme,
|
||||
|
||||
Reference in New Issue
Block a user