1
0
mirror of https://github.com/rancher/types.git synced 2025-09-09 00:48:56 +00:00

Update generated code

This commit is contained in:
Darren Shepherd
2017-11-13 13:02:12 -07:00
parent 5cd0a195a8
commit ebe3c76ce9
13 changed files with 362 additions and 220 deletions

View File

@@ -5,21 +5,35 @@ import (
)
const (
ClusterType = "cluster"
ClusterFieldAPIVersion = "apiVersion"
ClusterFieldKind = "kind"
ClusterFieldObjectMeta = "objectMeta"
ClusterFieldSpec = "spec"
ClusterFieldStatus = "status"
ClusterType = "cluster"
ClusterFieldAKSConfig = "aksConfig"
ClusterFieldAPIVersion = "apiVersion"
ClusterFieldAnnotations = "annotations"
ClusterFieldCreated = "created"
ClusterFieldGKEConfig = "gkeConfig"
ClusterFieldKind = "kind"
ClusterFieldLabels = "labels"
ClusterFieldName = "name"
ClusterFieldNamespace = "namespace"
ClusterFieldRKEConfig = "rkeConfig"
ClusterFieldRemoved = "removed"
ClusterFieldUuid = "uuid"
)
type Cluster struct {
types.Resource
APIVersion string `json:"apiVersion,omitempty"`
Kind string `json:"kind,omitempty"`
ObjectMeta ObjectMeta `json:"objectMeta,omitempty"`
Spec ClusterSpec `json:"spec,omitempty"`
Status *ClusterStatus `json:"status,omitempty"`
AKSConfig *AKSConfig `json:"aksConfig,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Created string `json:"created,omitempty"`
GKEConfig *GKEConfig `json:"gkeConfig,omitempty"`
Kind string `json:"kind,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
RKEConfig *RKEConfig `json:"rkeConfig,omitempty"`
Removed string `json:"removed,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
type ClusterCollection struct {
types.Collection

View File

@@ -5,21 +5,41 @@ import (
)
const (
ClusterNodeType = "clusterNode"
ClusterNodeFieldAPIVersion = "apiVersion"
ClusterNodeFieldKind = "kind"
ClusterNodeFieldObjectMeta = "objectMeta"
ClusterNodeFieldSpec = "spec"
ClusterNodeFieldStatus = "status"
ClusterNodeType = "clusterNode"
ClusterNodeFieldAPIVersion = "apiVersion"
ClusterNodeFieldAnnotations = "annotations"
ClusterNodeFieldConfigSource = "configSource"
ClusterNodeFieldCreated = "created"
ClusterNodeFieldExternalID = "externalID"
ClusterNodeFieldKind = "kind"
ClusterNodeFieldLabels = "labels"
ClusterNodeFieldName = "name"
ClusterNodeFieldNamespace = "namespace"
ClusterNodeFieldPodCIDR = "podCIDR"
ClusterNodeFieldProviderID = "providerID"
ClusterNodeFieldRemoved = "removed"
ClusterNodeFieldTaints = "taints"
ClusterNodeFieldUnschedulable = "unschedulable"
ClusterNodeFieldUuid = "uuid"
)
type ClusterNode struct {
types.Resource
APIVersion string `json:"apiVersion,omitempty"`
Kind string `json:"kind,omitempty"`
ObjectMeta ObjectMeta `json:"objectMeta,omitempty"`
Spec NodeSpec `json:"spec,omitempty"`
Status NodeStatus `json:"status,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
ConfigSource *NodeConfigSource `json:"configSource,omitempty"`
Created string `json:"created,omitempty"`
ExternalID string `json:"externalID,omitempty"`
Kind string `json:"kind,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
PodCIDR string `json:"podCIDR,omitempty"`
ProviderID string `json:"providerID,omitempty"`
Removed string `json:"removed,omitempty"`
Taints []Taint `json:"taints,omitempty"`
Unschedulable bool `json:"unschedulable,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
type ClusterNodeCollection struct {
types.Collection

View File

@@ -1,40 +1,22 @@
package client
const (
ObjectMetaType = "objectMeta"
ObjectMetaFieldAnnotations = "annotations"
ObjectMetaFieldClusterName = "clusterName"
ObjectMetaFieldCreationTimestamp = "creationTimestamp"
ObjectMetaFieldDeletionGracePeriodSeconds = "deletionGracePeriodSeconds"
ObjectMetaFieldDeletionTimestamp = "deletionTimestamp"
ObjectMetaFieldFinalizers = "finalizers"
ObjectMetaFieldGenerateName = "generateName"
ObjectMetaFieldGeneration = "generation"
ObjectMetaFieldInitializers = "initializers"
ObjectMetaFieldLabels = "labels"
ObjectMetaFieldName = "name"
ObjectMetaFieldNamespace = "namespace"
ObjectMetaFieldOwnerReferences = "ownerReferences"
ObjectMetaFieldResourceVersion = "resourceVersion"
ObjectMetaFieldSelfLink = "selfLink"
ObjectMetaFieldUID = "uid"
ObjectMetaType = "objectMeta"
ObjectMetaFieldAnnotations = "annotations"
ObjectMetaFieldCreated = "created"
ObjectMetaFieldLabels = "labels"
ObjectMetaFieldName = "name"
ObjectMetaFieldNamespace = "namespace"
ObjectMetaFieldRemoved = "removed"
ObjectMetaFieldUuid = "uuid"
)
type ObjectMeta struct {
Annotations map[string]string `json:"annotations,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
CreationTimestamp string `json:"creationTimestamp,omitempty"`
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"`
DeletionTimestamp string `json:"deletionTimestamp,omitempty"`
Finalizers []string `json:"finalizers,omitempty"`
GenerateName string `json:"generateName,omitempty"`
Generation int64 `json:"generation,omitempty"`
Initializers *Initializers `json:"initializers,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
SelfLink string `json:"selfLink,omitempty"`
UID string `json:"uid,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Created string `json:"created,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Removed string `json:"removed,omitempty"`
Uuid string `json:"uuid,omitempty"`
}

View File

@@ -1,24 +1,22 @@
package client
const (
ObjectMetaType = "objectMeta"
ObjectMetaFieldAnnotations = "annotations"
ObjectMetaFieldCreated = "created"
ObjectMetaFieldDeletionGracePeriodSeconds = "deletionGracePeriodSeconds"
ObjectMetaFieldLabels = "labels"
ObjectMetaFieldName = "name"
ObjectMetaFieldNamespace = "namespace"
ObjectMetaFieldRemoved = "removed"
ObjectMetaFieldUuid = "uuid"
ObjectMetaType = "objectMeta"
ObjectMetaFieldAnnotations = "annotations"
ObjectMetaFieldCreated = "created"
ObjectMetaFieldLabels = "labels"
ObjectMetaFieldName = "name"
ObjectMetaFieldNamespace = "namespace"
ObjectMetaFieldRemoved = "removed"
ObjectMetaFieldUuid = "uuid"
)
type ObjectMeta struct {
Annotations map[string]string `json:"annotations,omitempty"`
Created string `json:"created,omitempty"`
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Removed string `json:"removed,omitempty"`
Uuid string `json:"uuid,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Created string `json:"created,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Removed string `json:"removed,omitempty"`
Uuid string `json:"uuid,omitempty"`
}

View File

@@ -13,7 +13,6 @@ const (
PodFieldContainers = "containers"
PodFieldCreated = "created"
PodFieldDNSPolicy = "dnsPolicy"
PodFieldDeletionGracePeriodSeconds = "deletionGracePeriodSeconds"
PodFieldDeprecatedServiceAccount = "deprecatedServiceAccount"
PodFieldFsgid = "fsgid"
PodFieldGids = "gids"
@@ -52,7 +51,6 @@ type Pod struct {
Containers map[string]Container `json:"containers,omitempty"`
Created string `json:"created,omitempty"`
DNSPolicy string `json:"dnsPolicy,omitempty"`
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"`
DeprecatedServiceAccount string `json:"deprecatedServiceAccount,omitempty"`
Fsgid *int64 `json:"fsgid,omitempty"`
Gids []int64 `json:"gids,omitempty"`

View File

@@ -0,0 +1,105 @@
package v1
import (
"sync"
"github.com/rancher/norman/clientbase"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
type Interface interface {
RESTClient() rest.Interface
ProjectsGetter
RoleTemplatesGetter
PodSecurityPolicyTemplatesGetter
ProjectRoleBindingsGetter
}
type Client struct {
sync.Mutex
restClient rest.Interface
projectControllers map[string]ProjectController
roleTemplateControllers map[string]RoleTemplateController
podSecurityPolicyTemplateControllers map[string]PodSecurityPolicyTemplateController
projectRoleBindingControllers map[string]ProjectRoleBindingController
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
configConfig := dynamic.ContentConfig()
config.NegotiatedSerializer = configConfig.NegotiatedSerializer
}
restClient, err := rest.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
projectControllers: map[string]ProjectController{},
roleTemplateControllers: map[string]RoleTemplateController{},
podSecurityPolicyTemplateControllers: map[string]PodSecurityPolicyTemplateController{},
projectRoleBindingControllers: map[string]ProjectRoleBindingController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
type ProjectsGetter interface {
Projects(namespace string) ProjectInterface
}
func (c *Client) Projects(namespace string) ProjectInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ProjectResource, ProjectGroupVersionKind, projectFactory{})
return &projectClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type RoleTemplatesGetter interface {
RoleTemplates(namespace string) RoleTemplateInterface
}
func (c *Client) RoleTemplates(namespace string) RoleTemplateInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &RoleTemplateResource, RoleTemplateGroupVersionKind, roleTemplateFactory{})
return &roleTemplateClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type PodSecurityPolicyTemplatesGetter interface {
PodSecurityPolicyTemplates(namespace string) PodSecurityPolicyTemplateInterface
}
func (c *Client) PodSecurityPolicyTemplates(namespace string) PodSecurityPolicyTemplateInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &PodSecurityPolicyTemplateResource, PodSecurityPolicyTemplateGroupVersionKind, podSecurityPolicyTemplateFactory{})
return &podSecurityPolicyTemplateClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ProjectRoleBindingsGetter interface {
ProjectRoleBindings(namespace string) ProjectRoleBindingInterface
}
func (c *Client) ProjectRoleBindings(namespace string) ProjectRoleBindingInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ProjectRoleBindingResource, ProjectRoleBindingGroupVersionKind, projectRoleBindingFactory{})
return &projectRoleBindingClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -52,7 +49,7 @@ type PodSecurityPolicyTemplateInterface interface {
List(opts metav1.ListOptions) (*PodSecurityPolicyTemplateList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (PodSecurityPolicyTemplateController, error)
Controller() PodSecurityPolicyTemplateController
}
type podSecurityPolicyTemplateController struct {
@@ -83,35 +80,30 @@ func (c podSecurityPolicyTemplateFactory) List() runtime.Object {
return &PodSecurityPolicyTemplateList{}
}
func NewPodSecurityPolicyTemplateClient(namespace string, config rest.Config) (PodSecurityPolicyTemplateInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &PodSecurityPolicyTemplateResource, PodSecurityPolicyTemplateGroupVersionKind, podSecurityPolicyTemplateFactory{})
return &podSecurityPolicyTemplateClient{
objectClient: objectClient,
}, err
}
func (s *podSecurityPolicyTemplateClient) Controller() PodSecurityPolicyTemplateController {
s.client.Lock()
defer s.client.Unlock()
func (s *podSecurityPolicyTemplateClient) Controller() (PodSecurityPolicyTemplateController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.podSecurityPolicyTemplateControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(PodSecurityPolicyTemplateGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(PodSecurityPolicyTemplateGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &podSecurityPolicyTemplateController{
GenericController: genericController,
}
s.controller = &podSecurityPolicyTemplateController{
GenericController: controller,
}
return s.controller, nil
s.client.podSecurityPolicyTemplateControllers[s.ns] = c
return c
}
type podSecurityPolicyTemplateClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller PodSecurityPolicyTemplateController
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -52,7 +49,7 @@ type ProjectInterface interface {
List(opts metav1.ListOptions) (*ProjectList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (ProjectController, error)
Controller() ProjectController
}
type projectController struct {
@@ -83,35 +80,30 @@ func (c projectFactory) List() runtime.Object {
return &ProjectList{}
}
func NewProjectClient(namespace string, config rest.Config) (ProjectInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &ProjectResource, ProjectGroupVersionKind, projectFactory{})
return &projectClient{
objectClient: objectClient,
}, err
}
func (s *projectClient) Controller() ProjectController {
s.client.Lock()
defer s.client.Unlock()
func (s *projectClient) Controller() (ProjectController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.projectControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(ProjectGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(ProjectGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &projectController{
GenericController: genericController,
}
s.controller = &projectController{
GenericController: controller,
}
return s.controller, nil
s.client.projectControllers[s.ns] = c
return c
}
type projectClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ProjectController
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -52,7 +49,7 @@ type ProjectRoleBindingInterface interface {
List(opts metav1.ListOptions) (*ProjectRoleBindingList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (ProjectRoleBindingController, error)
Controller() ProjectRoleBindingController
}
type projectRoleBindingController struct {
@@ -83,35 +80,30 @@ func (c projectRoleBindingFactory) List() runtime.Object {
return &ProjectRoleBindingList{}
}
func NewProjectRoleBindingClient(namespace string, config rest.Config) (ProjectRoleBindingInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &ProjectRoleBindingResource, ProjectRoleBindingGroupVersionKind, projectRoleBindingFactory{})
return &projectRoleBindingClient{
objectClient: objectClient,
}, err
}
func (s *projectRoleBindingClient) Controller() ProjectRoleBindingController {
s.client.Lock()
defer s.client.Unlock()
func (s *projectRoleBindingClient) Controller() (ProjectRoleBindingController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.projectRoleBindingControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(ProjectRoleBindingGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(ProjectRoleBindingGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &projectRoleBindingController{
GenericController: genericController,
}
s.controller = &projectRoleBindingController{
GenericController: controller,
}
return s.controller, nil
s.client.projectRoleBindingControllers[s.ns] = c
return c
}
type projectRoleBindingClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ProjectRoleBindingController
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -52,7 +49,7 @@ type RoleTemplateInterface interface {
List(opts metav1.ListOptions) (*RoleTemplateList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (RoleTemplateController, error)
Controller() RoleTemplateController
}
type roleTemplateController struct {
@@ -83,35 +80,30 @@ func (c roleTemplateFactory) List() runtime.Object {
return &RoleTemplateList{}
}
func NewRoleTemplateClient(namespace string, config rest.Config) (RoleTemplateInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &RoleTemplateResource, RoleTemplateGroupVersionKind, roleTemplateFactory{})
return &roleTemplateClient{
objectClient: objectClient,
}, err
}
func (s *roleTemplateClient) Controller() RoleTemplateController {
s.client.Lock()
defer s.client.Unlock()
func (s *roleTemplateClient) Controller() (RoleTemplateController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.roleTemplateControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(RoleTemplateGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(RoleTemplateGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &roleTemplateController{
GenericController: genericController,
}
s.controller = &roleTemplateController{
GenericController: controller,
}
return s.controller, nil
s.client.roleTemplateControllers[s.ns] = c
return c
}
type roleTemplateClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller RoleTemplateController
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -22,7 +19,7 @@ var (
Kind: "Cluster",
}
ClusterResource = metav1.APIResource{
Name: "clusters",
Name: "",
SingularName: "cluster",
Namespaced: false,
Kind: ClusterGroupVersionKind.Kind,
@@ -52,7 +49,7 @@ type ClusterInterface interface {
List(opts metav1.ListOptions) (*ClusterList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (ClusterController, error)
Controller() ClusterController
}
type clusterController struct {
@@ -83,35 +80,30 @@ func (c clusterFactory) List() runtime.Object {
return &ClusterList{}
}
func NewClusterClient(namespace string, config rest.Config) (ClusterInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &ClusterResource, ClusterGroupVersionKind, clusterFactory{})
return &clusterClient{
objectClient: objectClient,
}, err
}
func (s *clusterClient) Controller() ClusterController {
s.client.Lock()
defer s.client.Unlock()
func (s *clusterClient) Controller() (ClusterController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.clusterControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(ClusterGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(ClusterGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &clusterController{
GenericController: genericController,
}
s.controller = &clusterController{
GenericController: controller,
}
return s.controller, nil
s.client.clusterControllers[s.ns] = c
return c
}
type clusterClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ClusterController
}

View File

@@ -1,8 +1,6 @@
package v1
import (
"sync"
"context"
"github.com/rancher/norman/clientbase"
@@ -11,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
@@ -22,7 +19,7 @@ var (
Kind: "ClusterNode",
}
ClusterNodeResource = metav1.APIResource{
Name: "clusternodes",
Name: "",
SingularName: "clusternode",
Namespaced: false,
Kind: ClusterNodeGroupVersionKind.Kind,
@@ -52,7 +49,7 @@ type ClusterNodeInterface interface {
List(opts metav1.ListOptions) (*ClusterNodeList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() (ClusterNodeController, error)
Controller() ClusterNodeController
}
type clusterNodeController struct {
@@ -83,35 +80,30 @@ func (c clusterNodeFactory) List() runtime.Object {
return &ClusterNodeList{}
}
func NewClusterNodeClient(namespace string, config rest.Config) (ClusterNodeInterface, error) {
objectClient, err := clientbase.NewObjectClient(namespace, config, &ClusterNodeResource, ClusterNodeGroupVersionKind, clusterNodeFactory{})
return &clusterNodeClient{
objectClient: objectClient,
}, err
}
func (s *clusterNodeClient) Controller() ClusterNodeController {
s.client.Lock()
defer s.client.Unlock()
func (s *clusterNodeClient) Controller() (ClusterNodeController, error) {
s.Lock()
defer s.Unlock()
if s.controller != nil {
return s.controller, nil
c, ok := s.client.clusterNodeControllers[s.ns]
if ok {
return c
}
controller, err := controller.NewGenericController(ClusterNodeGroupVersionKind.Kind+"Controller",
genericController := controller.NewGenericController(ClusterNodeGroupVersionKind.Kind+"Controller",
s.objectClient)
if err != nil {
return nil, err
c = &clusterNodeController{
GenericController: genericController,
}
s.controller = &clusterNodeController{
GenericController: controller,
}
return s.controller, nil
s.client.clusterNodeControllers[s.ns] = c
return c
}
type clusterNodeClient struct {
sync.Mutex
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ClusterNodeController
}

View File

@@ -0,0 +1,73 @@
package v1
import (
"sync"
"github.com/rancher/norman/clientbase"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
type Interface interface {
RESTClient() rest.Interface
ClustersGetter
ClusterNodesGetter
}
type Client struct {
sync.Mutex
restClient rest.Interface
clusterControllers map[string]ClusterController
clusterNodeControllers map[string]ClusterNodeController
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
configConfig := dynamic.ContentConfig()
config.NegotiatedSerializer = configConfig.NegotiatedSerializer
}
restClient, err := rest.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
clusterControllers: map[string]ClusterController{},
clusterNodeControllers: map[string]ClusterNodeController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
type ClustersGetter interface {
Clusters(namespace string) ClusterInterface
}
func (c *Client) Clusters(namespace string) ClusterInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ClusterResource, ClusterGroupVersionKind, clusterFactory{})
return &clusterClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ClusterNodesGetter interface {
ClusterNodes(namespace string) ClusterNodeInterface
}
func (c *Client) ClusterNodes(namespace string) ClusterNodeInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ClusterNodeResource, ClusterNodeGroupVersionKind, clusterNodeFactory{})
return &clusterNodeClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}