mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 13:55:20 +00:00
Use aggregated discovery API to discovery API groups and resources
Use aggregated discovery API to discovery API groups and resources Fixes #7526 Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
"k8s.io/client-go/discovery"
|
||||
k8scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
kbclient "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
@@ -56,6 +57,9 @@ type Factory interface {
|
||||
// It adds Kubernetes and Velero types to its scheme. It uses the following priority to specify the cluster
|
||||
// configuration: --kubeconfig flag, KUBECONFIG environment variable, in-cluster configuration.
|
||||
KubebuilderWatchClient() (kbclient.WithWatch, error)
|
||||
// DiscoveryClient returns a Kubernetes discovery client. It uses the following priority to specify the cluster
|
||||
// configuration: --kubeconfig flag, KUBECONFIG environment variable, in-cluster configuration.
|
||||
DiscoveryClient() (discovery.AggregatedDiscoveryInterface, error)
|
||||
// SetBasename changes the basename for an already-constructed client.
|
||||
// This is useful for generating clients that require a different user-agent string below the root `velero`
|
||||
// command, such as the server subcommand.
|
||||
@@ -209,6 +213,14 @@ func (f *factory) KubebuilderWatchClient() (kbclient.WithWatch, error) {
|
||||
return kubebuilderWatchClient, nil
|
||||
}
|
||||
|
||||
func (f *factory) DiscoveryClient() (discovery.AggregatedDiscoveryInterface, error) {
|
||||
clientConfig, err := f.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return discovery.NewDiscoveryClientForConfig(clientConfig)
|
||||
}
|
||||
|
||||
func (f *factory) SetBasename(name string) {
|
||||
f.baseName = name
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Code generated by mockery v2.20.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.28.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
dynamic "k8s.io/client-go/dynamic"
|
||||
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
@@ -51,6 +53,32 @@ func (_m *Factory) ClientConfig() (*rest.Config, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DiscoveryClient provides a mock function with given fields:
|
||||
func (_m *Factory) DiscoveryClient() (discovery.AggregatedDiscoveryInterface, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 discovery.AggregatedDiscoveryInterface
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (discovery.AggregatedDiscoveryInterface, error)); ok {
|
||||
return rf()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() discovery.AggregatedDiscoveryInterface); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(discovery.AggregatedDiscoveryInterface)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DynamicClient provides a mock function with given fields:
|
||||
func (_m *Factory) DynamicClient() (dynamic.Interface, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
Reference in New Issue
Block a user