mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
[Federation][Kubefed] Add some faked methods on kubectl fake test API factory for kubefeds consumption
This commit is contained in:
parent
815b340f8d
commit
2ad49a642b
@ -20,6 +20,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
"github.com/emicklei/go-restful/swagger"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -224,6 +226,7 @@ type TestFactory struct {
|
|||||||
Err error
|
Err error
|
||||||
Command string
|
Command string
|
||||||
GenericPrinter bool
|
GenericPrinter bool
|
||||||
|
TmpDir string
|
||||||
|
|
||||||
ClientForMappingFunc func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
ClientForMappingFunc func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||||
UnstructuredClientForMappingFunc func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
UnstructuredClientForMappingFunc func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||||
@ -567,6 +570,19 @@ func (f *fakeAPIFactory) RESTClient() (*restclient.RESTClient, error) {
|
|||||||
return restClient, f.tf.Err
|
return restClient, f.tf.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *fakeAPIFactory) DiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
|
||||||
|
fakeClient := f.tf.Client.(*fake.RESTClient)
|
||||||
|
discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(f.tf.ClientConfig)
|
||||||
|
discoveryClient.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
|
||||||
|
|
||||||
|
cacheDir := filepath.Join(f.tf.TmpDir, ".kube", "cache", "discovery")
|
||||||
|
return cmdutil.NewCachedDiscoveryClient(discoveryClient, cacheDir, time.Duration(10*time.Minute)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *fakeAPIFactory) ClientSetForVersion(requiredVersion *schema.GroupVersion) (internalclientset.Interface, error) {
|
||||||
|
return f.ClientSet()
|
||||||
|
}
|
||||||
|
|
||||||
func (f *fakeAPIFactory) ClientConfig() (*restclient.Config, error) {
|
func (f *fakeAPIFactory) ClientConfig() (*restclient.Config, error) {
|
||||||
return f.tf.ClientConfig, f.tf.Err
|
return f.tf.ClientConfig, f.tf.Err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user