This commit is contained in:
Darren Shepherd
2020-01-30 22:37:59 -07:00
parent 19c6732de0
commit 8b42d0aff8
71 changed files with 4024 additions and 507 deletions

View File

@@ -2,25 +2,27 @@ package client
import (
"github.com/rancher/steve/pkg/attributes"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/steve/pkg/schemaserver/types"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
type Factory struct {
client dynamic.Interface
Config *rest.Config
}
func NewFactory(cfg *rest.Config) (*Factory, error) {
newCfg := *cfg
newCfg := rest.CopyConfig(cfg)
newCfg.QPS = 10000
newCfg.Burst = 100
c, err := dynamic.NewForConfig(&newCfg)
c, err := dynamic.NewForConfig(newCfg)
if err != nil {
return nil, err
}
return &Factory{
client: c,
Config: newCfg,
}, nil
}
@@ -28,11 +30,7 @@ func (p *Factory) DynamicClient() dynamic.Interface {
return p.client
}
func (p *Factory) Client(ctx *types.APIRequest, s *types.Schema) (dynamic.ResourceInterface, error) {
func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error) {
gvr := attributes.GVR(s)
if len(ctx.Namespaces) > 0 {
return p.client.Resource(gvr).Namespace(ctx.Namespaces[0]), nil
}
return p.client.Resource(gvr), nil
return p.client.Resource(gvr).Namespace(namespace), nil
}