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:
@@ -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,
|
||||
|
Reference in New Issue
Block a user