mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
Merge pull request #136691 from pohly/ktesting-deprecated-removal
ktesting: remove deprecated and unused functions
This commit is contained in:
commit
a773eb4838
6 changed files with 2 additions and 66 deletions
|
|
@ -164,12 +164,6 @@ func buildDescription(explain ...interface{}) string {
|
|||
return fmt.Sprintf(explain[0].(string), explain[1:]...)
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.Eventually instead.
|
||||
func Eventually[T any](tCtx TContext, cb func(TContext) T) gomega.AsyncAssertion {
|
||||
tCtx.Helper()
|
||||
return tCtx.Eventually(cb)
|
||||
}
|
||||
|
||||
// Eventually wraps [gomega.Eventually]. Supported argument types are:
|
||||
// - A function with a `tCtx ktesting.TContext` or `ctx context.Context`
|
||||
// parameter plus additional parameters and arbitrary return values.
|
||||
|
|
@ -251,12 +245,6 @@ func (tc *TC) AssertEventually(arg any) gomega.AsyncAssertion {
|
|||
return tc.newAsyncAssertion(gomega.NewWithT(assertTestingT{tc}).Eventually, arg)
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.Consistently instead.
|
||||
func Consistently[T any](tCtx TContext, cb func(TContext) T) gomega.AsyncAssertion {
|
||||
tCtx.Helper()
|
||||
return tCtx.Consistently(cb)
|
||||
}
|
||||
|
||||
// Consistently wraps [gomega.Consistently] the same way as [Eventually] wraps
|
||||
// [gomega.Eventually].
|
||||
func (tc *TC) Consistently(arg any) gomega.AsyncAssertion {
|
||||
|
|
|
|||
|
|
@ -27,11 +27,6 @@ import (
|
|||
"k8s.io/client-go/restmapper"
|
||||
)
|
||||
|
||||
// Deprecated: use tCtx.WithRESTConfig instead
|
||||
func WithRESTConfig(tCtx TContext, cfg *rest.Config) TContext {
|
||||
return tCtx.WithRESTConfig(cfg)
|
||||
}
|
||||
|
||||
// WithRESTConfig initializes all client-go clients with new clients
|
||||
// created for the config. The current test name gets included in the UserAgent.
|
||||
func (tc *TC) WithRESTConfig(cfg *rest.Config) TContext {
|
||||
|
|
@ -48,11 +43,6 @@ func (tc *TC) WithRESTConfig(cfg *rest.Config) TContext {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.WithClients instead
|
||||
func WithClients(tCtx TContext, cfg *rest.Config, mapper *restmapper.DeferredDiscoveryRESTMapper, client clientset.Interface, dynamic dynamic.Interface, apiextensions apiextensions.Interface) TContext {
|
||||
return tCtx.WithClients(cfg, mapper, client, dynamic, apiextensions)
|
||||
}
|
||||
|
||||
// WithClients uses an existing config and clients.
|
||||
func (tc *TC) WithClients(cfg *rest.Config, mapper *restmapper.DeferredDiscoveryRESTMapper, client clientset.Interface, dynamic dynamic.Interface, apiextensions apiextensions.Interface) TContext {
|
||||
tc = tc.clone()
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// Deprecated: use tCtx.WithError instead
|
||||
func WithError(tCtx TContext, err *error) (TContext, func()) {
|
||||
return tCtx.WithError(err)
|
||||
}
|
||||
|
||||
// WithError creates a context where test failures are collected and stored in
|
||||
// the provided error instance when the caller is done. Use it like this:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@ limitations under the License.
|
|||
|
||||
package ktesting
|
||||
|
||||
// Deprecated: use tCtx.WithStep instead
|
||||
func WithStep(tCtx TContext, step string) TContext {
|
||||
return tCtx.WithStep(step)
|
||||
}
|
||||
|
||||
// WithStep creates a context where a prefix is added to all errors and log
|
||||
// messages, similar to how errors are wrapped. This can be nested, leaving a
|
||||
// trail of "bread crumbs" that help figure out where in a test some problem
|
||||
|
|
@ -37,12 +32,6 @@ func (tc *TC) WithStep(step string) *TC {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.Step instead
|
||||
func Step(tCtx TContext, step string, cb func(tCtx TContext)) {
|
||||
tCtx.Helper()
|
||||
tCtx.Step(step, cb)
|
||||
}
|
||||
|
||||
// Step is useful when the context with the step information is
|
||||
// used more than once:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -296,11 +296,6 @@ func run(tc *TC, name string, syncTest bool, cb func(tc *TC)) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.WithContext instead
|
||||
func WithContext(tCtx TContext, ctx context.Context) TContext {
|
||||
return tCtx.WithContext(ctx)
|
||||
}
|
||||
|
||||
// WithContext constructs a new TContext with a different Context instance.
|
||||
// This can be used in callbacks which receive a Context, for example
|
||||
// from Gomega:
|
||||
|
|
@ -322,11 +317,6 @@ func (tc *TC) WithContext(ctx context.Context) TContext {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.WithValue instead
|
||||
func WithValue(tCtx TContext, key, val any) TContext {
|
||||
return tCtx.WithValue(key, val)
|
||||
}
|
||||
|
||||
// WithValue wraps [context.WithValue] such that the result is again a TContext.
|
||||
func (tc *TC) WithValue(key, val any) TContext {
|
||||
ctx := context.WithValue(tc, key, val)
|
||||
|
|
@ -480,7 +470,7 @@ func (tc *TC) CleanupCtx(cb func(TContext)) {
|
|||
if tb, ok := tc.TB().(ContextTB); ok {
|
||||
// Use context from base TB (most likely Ginkgo).
|
||||
tb.CleanupCtx(func(ctx context.Context) {
|
||||
tCtx := WithContext(tc, ctx)
|
||||
tCtx := tc.WithContext(ctx)
|
||||
cb(tCtx)
|
||||
})
|
||||
return
|
||||
|
|
@ -491,7 +481,7 @@ func (tc *TC) CleanupCtx(cb func(TContext)) {
|
|||
// context then has *no* deadline. In the code path above for
|
||||
// Ginkgo, Ginkgo is more sophisticated and also applies
|
||||
// timeouts to cleanup calls which accept a context.
|
||||
childCtx := WithContext(tc, context.WithoutCancel(tc))
|
||||
childCtx := tc.WithContext(context.WithoutCancel(tc))
|
||||
cb(childCtx)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ import (
|
|||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// Deprecated: use tCtx.WithCancel instead
|
||||
func WithCancel(tCtx TContext) TContext { return tCtx.WithCancel() }
|
||||
|
||||
// WithCancel sets up cancellation in a [TContext.Cleanup] callback and
|
||||
// constructs a new TContext where [TContext.Cancel] cancels only the new
|
||||
// context.
|
||||
|
|
@ -44,9 +41,6 @@ func (tc *TC) WithCancel() TContext {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.WithoutCancel instead
|
||||
func WithoutCancel(tCtx TContext) TContext { return tCtx.WithoutCancel() }
|
||||
|
||||
// WithoutCancel causes the returned context to ignore cancellation of its parent.
|
||||
// Calling Cancel will not cancel the parent either.
|
||||
// This matches [context.WithoutCancel].
|
||||
|
|
@ -59,11 +53,6 @@ func (tc *TC) WithoutCancel() TContext {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: use tCtx.WithTimeout instead
|
||||
func WithTimeout(tCtx TContext, timeout time.Duration, timeoutCause string) TContext {
|
||||
return tCtx.WithTimeout(timeout, timeoutCause)
|
||||
}
|
||||
|
||||
// WithTimeout sets up new context with a timeout. Canceling the timeout gets
|
||||
// registered in a cleanup callback. [TContext.Cancel] cancels only
|
||||
// the new context. The cause is used as reason why the context is canceled
|
||||
|
|
@ -78,11 +67,6 @@ func (tc *TC) WithTimeout(timeout time.Duration, timeoutCause string) TContext {
|
|||
return tc
|
||||
}
|
||||
|
||||
// Deprecated: used tCtx.WithLogger instead
|
||||
func WithLogger(tCtx TContext, logger klog.Logger) TContext {
|
||||
return tCtx.WithLogger(logger)
|
||||
}
|
||||
|
||||
// WithLogger constructs a new context with a different logger.
|
||||
func (tc *TC) WithLogger(logger klog.Logger) TContext {
|
||||
ctx := klog.NewContext(tc, logger)
|
||||
|
|
|
|||
Loading…
Reference in a new issue