client-go: expose all discovery methods

The underlying implementation has both. Exposing that in the result of
Discovery() makes it easier for consumers to call the WithContext methods
because they don't need to wrap with ToDiscoveryInterfaceWithContext().

This is a breaking Go API change because tests which implement
the interface have to be updated.

Kubernetes-commit: d8f70b87cec6888420e778bca1ea8022a6617140
This commit is contained in:
Patrick Ohly
2026-03-18 14:24:10 +01:00
committed by Kubernetes Publisher
parent 07eaa8b369
commit 6ecbabc519
3 changed files with 9 additions and 3 deletions

View File

@@ -109,6 +109,12 @@ type DiscoveryInterfaceWithContext interface {
WithLegacyWithContext(ctx context.Context) DiscoveryInterfaceWithContext
}
// DiscoveryInterfaces combines both interface variants.
type DiscoveryInterfaces interface {
DiscoveryInterface
DiscoveryInterfaceWithContext
}
func ToDiscoveryInterfaceWithContext(i DiscoveryInterface) DiscoveryInterfaceWithContext {
if i == nil {
return nil

View File

@@ -81,7 +81,7 @@ import (
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
Discovery() discovery.DiscoveryInterfaces
AdmissionregistrationV1() admissionregistrationv1.AdmissionregistrationV1Interface
AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface
AdmissionregistrationV1beta1() admissionregistrationv1beta1.AdmissionregistrationV1beta1Interface
@@ -461,7 +461,7 @@ func (c *Clientset) StoragemigrationV1beta1() storagemigrationv1beta1.Storagemig
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
func (c *Clientset) Discovery() discovery.DiscoveryInterfaces {
if c == nil {
return nil
}

View File

@@ -176,7 +176,7 @@ type Clientset struct {
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
func (c *Clientset) Discovery() discovery.DiscoveryInterfaces {
return c.discovery
}