1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-25 14:46:57 +00:00

Give access to unstructured client

This commit is contained in:
Darren Shepherd
2017-12-16 01:25:56 -07:00
parent 60e03d42c9
commit f07f35f319

View File

@@ -6,6 +6,7 @@ import (
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
@@ -18,6 +19,17 @@ type ObjectFactory interface {
List() runtime.Object
}
type UnstructuredObjectFactory struct {
}
func (u *UnstructuredObjectFactory) Object() runtime.Object {
return &unstructured.Unstructured{}
}
func (u *UnstructuredObjectFactory) List() runtime.Object {
return &unstructured.UnstructuredList{}
}
type ObjectClient struct {
restClient rest.Interface
resource *metav1.APIResource
@@ -36,6 +48,16 @@ func NewObjectClient(namespace string, restClient rest.Interface, apiResource *m
}
}
func (p *ObjectClient) UnstructuredClient() *ObjectClient {
return &ObjectClient{
restClient: p.restClient,
resource: p.resource,
gvk: p.gvk,
ns: p.ns,
Factory: &UnstructuredObjectFactory{},
}
}
func (p *ObjectClient) getAPIPrefix() string {
if p.gvk.Group == "" {
return "api"