Add caching for discovery info

This commit is contained in:
Dr. Stefan Schimanski
2016-10-24 12:58:47 +02:00
parent 5a2c473c1c
commit 14ce6f6065
8 changed files with 711 additions and 43 deletions

View File

@@ -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
}