1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-26 15:18:06 +00:00

Allow discovery of API clients

This commit is contained in:
Darren Shepherd
2019-01-11 16:55:37 -07:00
parent ad8537c903
commit 1fd5af67a4
5 changed files with 148 additions and 43 deletions

View File

@@ -5,6 +5,8 @@ import (
"github.com/rancher/norman/objectclient"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
)
type Client interface {
@@ -13,24 +15,38 @@ type Client interface {
}
type Processor struct {
setID string
codeVersion string
clients map[schema.GroupVersionKind]Client
setID string
codeVersion string
discovery discovery.DiscoveryInterface
restConfig rest.Config
allowSlowPath string
slowClient rest.HTTPClient
clients map[schema.GroupVersionKind]Client
}
func NewProcessor(setID string) Processor {
return Processor{
func NewProcessor(setID string) *Processor {
return &Processor{
setID: setID,
clients: map[schema.GroupVersionKind]Client{},
}
}
func (t Processor) CodeVersion(version string) Processor {
func (t *Processor) SetID() string {
return t.setID
}
func (t *Processor) CodeVersion(version string) *Processor {
t.codeVersion = version
return t
}
func (t Processor) Client(clients ...Client) Processor {
func (t *Processor) AllowDiscovery(discovery discovery.DiscoveryInterface, restConfig rest.Config) *Processor {
t.discovery = discovery
t.restConfig = restConfig
return t
}
func (t *Processor) Client(clients ...Client) *Processor {
// ensure cache is enabled
for _, client := range clients {
client.Generic()
@@ -50,6 +66,8 @@ func (t Processor) NewDesiredSet(owner runtime.Object, objs *ObjectSet) *Desired
objs = &ObjectSet{}
}
return &DesiredSet{
discovery: t.discovery,
restConfig: t.restConfig,
remove: remove,
objs: objs,
setID: t.setID,