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: bd399917375d2a1d77c04f8dfd67a67301af9721
This commit is contained in:
Patrick Ohly
2026-01-23 11:20:40 +01:00
committed by Kubernetes Publisher
parent 15adbb6352
commit fb9e30a1f9

View File

@@ -34,10 +34,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 {