mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Add caching for discovery info
This commit is contained in:
@@ -133,6 +133,17 @@ func newExternalScheme() (*runtime.Scheme, meta.RESTMapper, runtime.Codec) {
|
||||
return scheme, mapper, codec
|
||||
}
|
||||
|
||||
type fakeCachedDiscoveryClient struct {
|
||||
discovery.DiscoveryInterface
|
||||
}
|
||||
|
||||
func (d *fakeCachedDiscoveryClient) Fresh() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *fakeCachedDiscoveryClient) Invalidate() {
|
||||
}
|
||||
|
||||
type TestFactory struct {
|
||||
Mapper meta.RESTMapper
|
||||
Typer runtime.ObjectTyper
|
||||
@@ -164,6 +175,14 @@ func NewTestFactory() (cmdutil.Factory, *TestFactory, runtime.Codec, runtime.Neg
|
||||
}, t, codec, negotiatedSerializer
|
||||
}
|
||||
|
||||
func (f *FakeFactory) DiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
|
||||
discoveryClient, err := discovery.NewDiscoveryClientForConfig(f.tf.ClientConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &fakeCachedDiscoveryClient{DiscoveryInterface: discoveryClient}, nil
|
||||
}
|
||||
|
||||
func (f *FakeFactory) FlagSet() *pflag.FlagSet {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user