1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-03 07:54:14 +00:00

Vendor update

This commit is contained in:
galal-hussein
2017-12-02 19:07:16 +02:00
parent e93431d7e5
commit fd07818809
26 changed files with 1714 additions and 41 deletions

View File

@@ -117,7 +117,6 @@ func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
r, err := p.restClient.Get().
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
Prefix("watch").
Namespace(p.ns).
NamespaceIfScoped(p.ns, p.resource.Namespaced).
Resource(p.resource.Name).
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).

View File

@@ -24,7 +24,9 @@ type HandlerFunc func(key string) error
type GenericController interface {
Informer() cache.SharedIndexInformer
AddHandler(handler HandlerFunc)
HandlerCount() int
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
@@ -35,6 +37,7 @@ type genericController struct {
queue workqueue.RateLimitingInterface
name string
running bool
synced bool
}
func NewGenericController(name string, objectClient *clientbase.ObjectClient) GenericController {
@@ -53,6 +56,10 @@ func NewGenericController(name string, objectClient *clientbase.ObjectClient) Ge
}
}
func (g *genericController) HandlerCount() int {
return len(g.handlers)
}
func (g *genericController) Informer() cache.SharedIndexInformer {
return g.informer
}
@@ -69,10 +76,51 @@ func (g *genericController) AddHandler(handler HandlerFunc) {
g.handlers = append(g.handlers, handler)
}
func (g *genericController) Sync(ctx context.Context) error {
g.Lock()
defer g.Unlock()
return g.sync(ctx)
}
func (g *genericController) sync(ctx context.Context) error {
if g.synced {
return nil
}
defer utilruntime.HandleCrash()
g.informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: g.queueObject,
UpdateFunc: func(_, obj interface{}) {
g.queueObject(obj)
},
DeleteFunc: g.queueObject,
})
logrus.Infof("Syncing %s Controller", g.name)
go g.informer.Run(ctx.Done())
if !cache.WaitForCacheSync(ctx.Done(), g.informer.HasSynced) {
return fmt.Errorf("failed to sync controller %s", g.name)
}
logrus.Infof("Syncing %s Controller Done", g.name)
g.synced = true
return nil
}
func (g *genericController) Start(ctx context.Context, threadiness int) error {
g.Lock()
defer g.Unlock()
if !g.synced {
if err := g.sync(ctx); err != nil {
return err
}
}
if !g.running {
go g.run(ctx, threadiness)
}
@@ -92,22 +140,6 @@ func (g *genericController) run(ctx context.Context, threadiness int) {
defer utilruntime.HandleCrash()
defer g.queue.ShutDown()
g.informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: g.queueObject,
UpdateFunc: func(_, obj interface{}) {
g.queueObject(obj)
},
DeleteFunc: g.queueObject,
})
logrus.Infof("Starting %s Controller", g.name)
go g.informer.Run(ctx.Done())
if !cache.WaitForCacheSync(ctx.Done(), g.informer.HasSynced) {
return
}
for i := 0; i < threadiness; i++ {
go wait.Until(g.runWorker, time.Second, ctx.Done())
}

40
vendor/github.com/rancher/norman/controller/starter.go generated vendored Normal file
View File

@@ -0,0 +1,40 @@
package controller
import (
"context"
"golang.org/x/sync/errgroup"
)
type Starter interface {
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
func SyncThenSync(ctx context.Context, threadiness int, starters ...Starter) error {
if err := Sync(ctx, starters...); err != nil {
return err
}
return Start(ctx, threadiness, starters...)
}
func Sync(ctx context.Context, starters ...Starter) error {
eg, _ := errgroup.WithContext(ctx)
for _, starter := range starters {
func(starter Starter) {
eg.Go(func() error {
return starter.Sync(ctx)
})
}(starter)
}
return eg.Wait()
}
func Start(ctx context.Context, threadiness int, starters ...Starter) error {
for _, starter := range starters {
if err := starter.Start(ctx, threadiness); err != nil {
return err
}
}
return nil
}

View File

@@ -1,6 +1,10 @@
package definition
import "strings"
import (
"strings"
"github.com/rancher/norman/types/convert"
)
func IsMapType(fieldType string) bool {
return strings.HasPrefix(fieldType, "map[") && strings.HasSuffix(fieldType, "]")
@@ -14,6 +18,10 @@ func IsReferenceType(fieldType string) bool {
return strings.HasPrefix(fieldType, "reference[") && strings.HasSuffix(fieldType, "]")
}
func HasReferenceType(fieldType string) bool {
return strings.Contains(fieldType, "reference[")
}
func SubType(fieldType string) string {
i := strings.Index(fieldType, "[")
if i <= 0 || i >= len(fieldType)-1 {
@@ -22,3 +30,12 @@ func SubType(fieldType string) string {
return fieldType[i+1 : len(fieldType)-1]
}
func GetType(data map[string]interface{}) string {
parts := strings.Split(GetFullType(data), "/")
return parts[len(parts)-1]
}
func GetFullType(data map[string]interface{}) string {
return convert.ToString(data["type"])
}

View File

@@ -1,6 +1,8 @@
package types
import (
"fmt"
"github.com/rancher/norman/types/definition"
)
@@ -67,7 +69,7 @@ func (t *typeMapper) FromInternal(data map[string]interface{}) {
data["type"] = t.typeName
}
name, _ := data["name"].(string)
namespace, _ := data["namespace"].(string)
namespace, _ := data["namespaceId"].(string)
if _, ok := data["id"]; !ok {
if name != "" {
@@ -106,7 +108,7 @@ func (t *typeMapper) ToInternal(data map[string]interface{}) {
func (t *typeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
t.subSchemas = map[string]*Schema{}
t.subArraySchemas = map[string]*Schema{}
t.typeName = schema.ID
t.typeName = fmt.Sprintf("%s/schemas/%s", schema.Version.Path, schema.ID)
mapperSchema := schema
if schema.InternalSchema != nil {

View File

@@ -142,10 +142,14 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
}
mappers := s.mapper(&schema.Version, schema.ID)
if schema.CanList() {
mappers = append(s.DefaultMappers, mappers...)
if s.DefaultMappers != nil {
if schema.CanList() {
mappers = append(s.DefaultMappers(), mappers...)
}
}
if s.DefaultPostMappers != nil {
mappers = append(mappers, s.DefaultPostMappers()...)
}
mappers = append(mappers, s.DefaultPostMappers...)
if len(mappers) > 0 {
copy, err := s.newSchemaFromType(version, t, typeName)
@@ -174,7 +178,7 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
schema.Mapper = mapper
s.AddSchema(schema)
return schema, nil
return schema, s.Err()
}
func jsonName(f reflect.StructField) string {

View File

@@ -15,12 +15,14 @@ type SchemaCollection struct {
type SchemaInitFunc func(*Schemas) *Schemas
type MappersFactory func() []Mapper
type Schemas struct {
schemasByPath map[string]map[string]*Schema
schemasBySubContext map[string]*Schema
mappers map[string]map[string][]Mapper
DefaultMappers []Mapper
DefaultPostMappers []Mapper
DefaultMappers MappersFactory
DefaultPostMappers MappersFactory
versions []APIVersion
schemas []*Schema
errors []error
@@ -63,7 +65,7 @@ func (s *Schemas) AddSchema(schema *Schema) *Schemas {
s.errors = append(s.errors, fmt.Errorf("ID is not set on schema: %v", schema))
return s
}
if schema.Version.Path == "" || schema.Version.Group == "" || schema.Version.Version == "" {
if schema.Version.Path == "" || schema.Version.Version == "" {
s.errors = append(s.errors, fmt.Errorf("version is not set on schema: %s", schema.ID))
return s
}

View File

@@ -126,6 +126,7 @@ type QueryOptions struct {
Sort Sort
Pagination *Pagination
Conditions []*QueryCondition
Options map[string]string
}
type ReferenceValidator interface {
@@ -153,4 +154,5 @@ type Store interface {
Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error)
Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error)
Delete(apiContext *APIContext, schema *Schema, id string) error
Watch(apiContext *APIContext, schema *Schema, opt QueryOptions) (chan map[string]interface{}, error)
}

View File

@@ -89,7 +89,7 @@ type Schema struct {
Version APIVersion `json:"version"`
PluralName string `json:"pluralName,omitempty"`
ResourceMethods []string `json:"resourceMethods,omitempty"`
ResourceFields map[string]Field `json:"resourceFields,omitempty"`
ResourceFields map[string]Field `json:"resourceFields"`
ResourceActions map[string]Action `json:"resourceActions,omitempty"`
CollectionMethods []string `json:"collectionMethods,omitempty"`
CollectionFields map[string]Field `json:"collectionFields,omitempty"`

View File

@@ -35,6 +35,8 @@ type Cluster struct {
}
type ClusterSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
GoogleKubernetesEngineConfig *GoogleKubernetesEngineConfig `json:"googleKubernetesEngineConfig,omitempty"`
AzureKubernetesServiceConfig *AzureKubernetesServiceConfig `json:"azureKubernetesServiceConfig,omitempty"`
RancherKubernetesEngineConfig *RancherKubernetesEngineConfig `json:"rancherKubernetesEngineConfig,omitempty"`
@@ -53,10 +55,12 @@ type ClusterStatus struct {
Capacity v1.ResourceList `json:"capacity,omitempty"`
Allocatable v1.ResourceList `json:"allocatable,omitempty"`
AppliedSpec ClusterSpec `json:"appliedSpec,omitempty"`
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
}
type ClusterComponentStatus struct {
Name string
Name string `json:"name"`
Conditions []v1.ComponentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"`
}
@@ -95,8 +99,8 @@ type GoogleKubernetesEngineConfig struct {
// The map of Kubernetes labels (key/value pairs) to be applied
// to each node.
Labels map[string]string `json:"labels,omitempty"`
// The path to the credential file(key.json)
CredentialPath string `json:"credentialPath,omitempty"`
// The content of the credential file(key.json)
Credential string `json:"credential,omitempty"`
// Enable alpha feature
EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty"`
}
@@ -116,8 +120,8 @@ type RancherKubernetesEngineConfig struct {
Authentication AuthConfig `yaml:"auth" json:"auth,omitempty"`
// YAML manifest for user provided addons to be deployed on the cluster
Addons string `yaml:"addons" json:"addons,omitempty"`
// SSH Private Key Path
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
// List of images used internally for proxy, cert downlaod and kubedns
RKEImages map[string]string `yaml:"rke_images" json:"rke_images,omitempty"`
}
type RKEConfigNode struct {
@@ -133,6 +137,10 @@ type RKEConfigNode struct {
User string `yaml:"user" json:"user,omitempty"`
// Optional - Docker socket on the node that will be used in tunneling
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
// SSH Private Key
SSHKey string `yaml:"ssh_key" json:"sshKey,omitempty"`
// SSH Private Key Path
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
}
type RKEConfigServices struct {
@@ -212,7 +220,172 @@ type AuthConfig struct {
// Authentication options
Options map[string]string `yaml:"options" json:"options,omitempty"`
}
type ClusterNode struct {
v1.Node
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the cluster node. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
v1.NodeSpec `json:"spec,omitempty"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status ClusterNodeStatus `json:"status"`
NodeName string
ClusterName string
}
type ClusterNodeStatus struct {
v1.NodeStatus
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
}
type MachineTemplate struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineTemplateSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineTemplateStatus `json:"status"`
}
type MachineTemplateStatus struct {
Conditions []MachineTemplateCondition `json:"conditions"`
}
type MachineTemplateCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineTemplateSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
FlavorPrefix string `json:"flavorPrefix"`
Driver string `json:"driver"`
SecretValues map[string]string `json:"secretValues"`
SecretName string `norman:"type=reference[/v1-cluster/schemas/globalSecret]"`
PublicValues map[string]string `json:"publicValues"`
}
type Machine struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineStatus `json:"status"`
}
type MachineStatus struct {
Conditions []MachineCondition `json:"conditions"`
}
type MachineCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineSpec struct {
ClusterName string `norman:"type=reference[cluster]"`
ExternalID string `json:"externalId"`
MachineTemplateName string `norman:"type=reference[machineTemplate]"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Hostname string `json:"hostname"`
Driver string `json:"driver"`
MachineGeneralParams `json:",inline"`
AmazonEC2Config AmazonEC2Config `json:"amazonEc2Config"`
AzureConfig AzureConfig `json:"azureConfig"`
DigitalOceanConfig DigitalOceanConfig `json:"digitalOceanConfig"`
}
type AmazonEC2Config struct {
}
type AzureConfig struct {
}
type DigitalOceanConfig struct {
}
type MachineGeneralParams struct {
AuthCertificateAuthority string `json:"authCertificateAuthority"`
AuthKey string `json:"authKey"`
EngineInstallURL string `json:"engineInstallURL"`
DockerVersion string `json:"dockerVersion"`
EngineOpt map[string]string `json:"engineOpt"`
EngineInsecureRegistry []string `json:"engineInsecureRegistry"`
EngineRegistryMirror []string `json:"engineRegistryMirror"`
EngineLabel map[string]string `json:"engineLabel"`
EngineStorageDriver string `json:"engineStorageDriver"`
EngineEnv map[string]string `json:"engineEnv"`
}
type MachineDriver struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MachineDriverSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status MachineDriverStatus `json:"status"`
}
type MachineDriverStatus struct {
Conditions []MachineDriverCondition `json:"conditions"`
}
type MachineDriverCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineDriverSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
URL string `json:"url"`
ExternalID string `json:"externalId"`
Builtin bool `json:"builtin"`
DefaultActive bool `json:"defaultActive"`
ActivateOnCreate bool `json:"activateOnCreate"`
Checksum string `json:"checksum"`
UIURL string `json:"uiUrl"`
}

View File

@@ -5,7 +5,9 @@ import (
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
@@ -34,14 +36,22 @@ type ClusterList struct {
type ClusterHandlerFunc func(key string, obj *Cluster) error
type ClusterLister interface {
List(namespace string, selector labels.Selector) (ret []*Cluster, err error)
Get(namespace, name string) (*Cluster, error)
}
type ClusterController interface {
Informer() cache.SharedIndexInformer
Lister() ClusterLister
AddHandler(handler ClusterHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ClusterInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*Cluster) (*Cluster, error)
Get(name string, opts metav1.GetOptions) (*Cluster, error)
Update(*Cluster) (*Cluster, error)
@@ -52,10 +62,41 @@ type ClusterInterface interface {
Controller() ClusterController
}
type clusterLister struct {
controller *clusterController
}
func (l *clusterLister) List(namespace string, selector labels.Selector) (ret []*Cluster, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*Cluster))
})
return
}
func (l *clusterLister) Get(namespace, name string) (*Cluster, error) {
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ClusterGroupVersionKind.Group,
Resource: "cluster",
}, name)
}
return obj.(*Cluster), nil
}
type clusterController struct {
controller.GenericController
}
func (c *clusterController) Lister() ClusterLister {
return &clusterLister{
controller: c,
}
}
func (c *clusterController) AddHandler(handler ClusterHandlerFunc) {
c.GenericController.AddHandler(func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
@@ -97,6 +138,7 @@ func (s *clusterClient) Controller() ClusterController {
}
s.client.clusterControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
@@ -108,6 +150,10 @@ type clusterClient struct {
controller ClusterController
}
func (s *clusterClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *clusterClient) Create(o *Cluster) (*Cluster, error) {
obj, err := s.objectClient.Create(o)
return obj.(*Cluster), err

View File

@@ -5,7 +5,9 @@ import (
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
@@ -34,14 +36,22 @@ type ClusterNodeList struct {
type ClusterNodeHandlerFunc func(key string, obj *ClusterNode) error
type ClusterNodeLister interface {
List(namespace string, selector labels.Selector) (ret []*ClusterNode, err error)
Get(namespace, name string) (*ClusterNode, error)
}
type ClusterNodeController interface {
Informer() cache.SharedIndexInformer
Lister() ClusterNodeLister
AddHandler(handler ClusterNodeHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ClusterNodeInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*ClusterNode) (*ClusterNode, error)
Get(name string, opts metav1.GetOptions) (*ClusterNode, error)
Update(*ClusterNode) (*ClusterNode, error)
@@ -52,10 +62,41 @@ type ClusterNodeInterface interface {
Controller() ClusterNodeController
}
type clusterNodeLister struct {
controller *clusterNodeController
}
func (l *clusterNodeLister) List(namespace string, selector labels.Selector) (ret []*ClusterNode, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*ClusterNode))
})
return
}
func (l *clusterNodeLister) Get(namespace, name string) (*ClusterNode, error) {
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ClusterNodeGroupVersionKind.Group,
Resource: "clusterNode",
}, name)
}
return obj.(*ClusterNode), nil
}
type clusterNodeController struct {
controller.GenericController
}
func (c *clusterNodeController) Lister() ClusterNodeLister {
return &clusterNodeLister{
controller: c,
}
}
func (c *clusterNodeController) AddHandler(handler ClusterNodeHandlerFunc) {
c.GenericController.AddHandler(func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
@@ -97,6 +138,7 @@ func (s *clusterNodeClient) Controller() ClusterNodeController {
}
s.client.clusterNodeControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
@@ -108,6 +150,10 @@ type clusterNodeClient struct {
controller ClusterNodeController
}
func (s *clusterNodeClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *clusterNodeClient) Create(o *ClusterNode) (*ClusterNode, error) {
obj, err := s.objectClient.Create(o)
return obj.(*ClusterNode), err

View File

@@ -5,6 +5,22 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AmazonEC2Config) DeepCopyInto(out *AmazonEC2Config) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AmazonEC2Config.
func (in *AmazonEC2Config) DeepCopy() *AmazonEC2Config {
if in == nil {
return nil
}
out := new(AmazonEC2Config)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AuthConfig) DeepCopyInto(out *AuthConfig) {
*out = *in
@@ -28,6 +44,22 @@ func (in *AuthConfig) DeepCopy() *AuthConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AzureConfig) DeepCopyInto(out *AzureConfig) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureConfig.
func (in *AzureConfig) DeepCopy() *AzureConfig {
if in == nil {
return nil
}
out := new(AzureConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AzureKubernetesServiceConfig) DeepCopyInto(out *AzureKubernetesServiceConfig) {
*out = *in
@@ -170,7 +202,10 @@ func (in *ClusterList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterNode) DeepCopyInto(out *ClusterNode) {
*out = *in
in.Node.DeepCopyInto(&out.Node)
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.NodeSpec.DeepCopyInto(&out.NodeSpec)
in.Status.DeepCopyInto(&out.Status)
return
}
@@ -227,6 +262,37 @@ func (in *ClusterNodeList) DeepCopyObject() runtime.Object {
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterNodeStatus) DeepCopyInto(out *ClusterNodeStatus) {
*out = *in
in.NodeStatus.DeepCopyInto(&out.NodeStatus)
if in.Requested != nil {
in, out := &in.Requested, &out.Requested
*out = make(core_v1.ResourceList, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
if in.Limits != nil {
in, out := &in.Limits, &out.Limits
*out = make(core_v1.ResourceList, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterNodeStatus.
func (in *ClusterNodeStatus) DeepCopy() *ClusterNodeStatus {
if in == nil {
return nil
}
out := new(ClusterNodeStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
*out = *in
@@ -300,6 +366,20 @@ func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) {
}
}
in.AppliedSpec.DeepCopyInto(&out.AppliedSpec)
if in.Requested != nil {
in, out := &in.Requested, &out.Requested
*out = make(core_v1.ResourceList, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
if in.Limits != nil {
in, out := &in.Limits, &out.Limits
*out = make(core_v1.ResourceList, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
return
}
@@ -313,6 +393,22 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DigitalOceanConfig) DeepCopyInto(out *DigitalOceanConfig) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DigitalOceanConfig.
func (in *DigitalOceanConfig) DeepCopy() *DigitalOceanConfig {
if in == nil {
return nil
}
out := new(DigitalOceanConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ETCDService) DeepCopyInto(out *ETCDService) {
*out = *in
@@ -421,6 +517,419 @@ func (in *KubeproxyService) DeepCopy() *KubeproxyService {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Machine) DeepCopyInto(out *Machine) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Machine.
func (in *Machine) DeepCopy() *Machine {
if in == nil {
return nil
}
out := new(Machine)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Machine) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineCondition) DeepCopyInto(out *MachineCondition) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineCondition.
func (in *MachineCondition) DeepCopy() *MachineCondition {
if in == nil {
return nil
}
out := new(MachineCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineDriver) DeepCopyInto(out *MachineDriver) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDriver.
func (in *MachineDriver) DeepCopy() *MachineDriver {
if in == nil {
return nil
}
out := new(MachineDriver)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MachineDriver) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineDriverCondition) DeepCopyInto(out *MachineDriverCondition) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDriverCondition.
func (in *MachineDriverCondition) DeepCopy() *MachineDriverCondition {
if in == nil {
return nil
}
out := new(MachineDriverCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineDriverList) DeepCopyInto(out *MachineDriverList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]MachineDriver, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDriverList.
func (in *MachineDriverList) DeepCopy() *MachineDriverList {
if in == nil {
return nil
}
out := new(MachineDriverList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MachineDriverList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineDriverSpec) DeepCopyInto(out *MachineDriverSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDriverSpec.
func (in *MachineDriverSpec) DeepCopy() *MachineDriverSpec {
if in == nil {
return nil
}
out := new(MachineDriverSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineDriverStatus) DeepCopyInto(out *MachineDriverStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]MachineDriverCondition, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDriverStatus.
func (in *MachineDriverStatus) DeepCopy() *MachineDriverStatus {
if in == nil {
return nil
}
out := new(MachineDriverStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineGeneralParams) DeepCopyInto(out *MachineGeneralParams) {
*out = *in
if in.EngineOpt != nil {
in, out := &in.EngineOpt, &out.EngineOpt
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.EngineInsecureRegistry != nil {
in, out := &in.EngineInsecureRegistry, &out.EngineInsecureRegistry
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.EngineRegistryMirror != nil {
in, out := &in.EngineRegistryMirror, &out.EngineRegistryMirror
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.EngineLabel != nil {
in, out := &in.EngineLabel, &out.EngineLabel
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.EngineEnv != nil {
in, out := &in.EngineEnv, &out.EngineEnv
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineGeneralParams.
func (in *MachineGeneralParams) DeepCopy() *MachineGeneralParams {
if in == nil {
return nil
}
out := new(MachineGeneralParams)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineList) DeepCopyInto(out *MachineList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Machine, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineList.
func (in *MachineList) DeepCopy() *MachineList {
if in == nil {
return nil
}
out := new(MachineList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MachineList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineSpec) DeepCopyInto(out *MachineSpec) {
*out = *in
in.MachineGeneralParams.DeepCopyInto(&out.MachineGeneralParams)
out.AmazonEC2Config = in.AmazonEC2Config
out.AzureConfig = in.AzureConfig
out.DigitalOceanConfig = in.DigitalOceanConfig
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSpec.
func (in *MachineSpec) DeepCopy() *MachineSpec {
if in == nil {
return nil
}
out := new(MachineSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineStatus) DeepCopyInto(out *MachineStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]MachineCondition, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineStatus.
func (in *MachineStatus) DeepCopy() *MachineStatus {
if in == nil {
return nil
}
out := new(MachineStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineTemplate) DeepCopyInto(out *MachineTemplate) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineTemplate.
func (in *MachineTemplate) DeepCopy() *MachineTemplate {
if in == nil {
return nil
}
out := new(MachineTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MachineTemplate) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineTemplateCondition) DeepCopyInto(out *MachineTemplateCondition) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineTemplateCondition.
func (in *MachineTemplateCondition) DeepCopy() *MachineTemplateCondition {
if in == nil {
return nil
}
out := new(MachineTemplateCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineTemplateList) DeepCopyInto(out *MachineTemplateList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]MachineTemplate, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineTemplateList.
func (in *MachineTemplateList) DeepCopy() *MachineTemplateList {
if in == nil {
return nil
}
out := new(MachineTemplateList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MachineTemplateList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineTemplateSpec) DeepCopyInto(out *MachineTemplateSpec) {
*out = *in
if in.SecretValues != nil {
in, out := &in.SecretValues, &out.SecretValues
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.PublicValues != nil {
in, out := &in.PublicValues, &out.PublicValues
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineTemplateSpec.
func (in *MachineTemplateSpec) DeepCopy() *MachineTemplateSpec {
if in == nil {
return nil
}
out := new(MachineTemplateSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MachineTemplateStatus) DeepCopyInto(out *MachineTemplateStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]MachineTemplateCondition, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineTemplateStatus.
func (in *MachineTemplateStatus) DeepCopy() *MachineTemplateStatus {
if in == nil {
return nil
}
out := new(MachineTemplateStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) {
*out = *in
@@ -500,6 +1009,13 @@ func (in *RancherKubernetesEngineConfig) DeepCopyInto(out *RancherKubernetesEngi
in.Services.DeepCopyInto(&out.Services)
in.Network.DeepCopyInto(&out.Network)
in.Authentication.DeepCopyInto(&out.Authentication)
if in.RKEImages != nil {
in, out := &in.RKEImages, &out.RKEImages
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}

View File

@@ -1,26 +1,36 @@
package v1
import (
"context"
"sync"
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
ClustersGetter
ClusterNodesGetter
MachinesGetter
MachineDriversGetter
MachineTemplatesGetter
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
clusterControllers map[string]ClusterController
clusterNodeControllers map[string]ClusterNodeController
clusterControllers map[string]ClusterController
clusterNodeControllers map[string]ClusterNodeController
machineControllers map[string]MachineController
machineDriverControllers map[string]MachineDriverController
machineTemplateControllers map[string]MachineTemplateController
}
func NewForConfig(config rest.Config) (Interface, error) {
@@ -37,8 +47,11 @@ func NewForConfig(config rest.Config) (Interface, error) {
return &Client{
restClient: restClient,
clusterControllers: map[string]ClusterController{},
clusterNodeControllers: map[string]ClusterNodeController{},
clusterControllers: map[string]ClusterController{},
clusterNodeControllers: map[string]ClusterNodeController{},
machineControllers: map[string]MachineController{},
machineDriverControllers: map[string]MachineDriverController{},
machineTemplateControllers: map[string]MachineTemplateController{},
}, nil
}
@@ -46,6 +59,14 @@ func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type ClustersGetter interface {
Clusters(namespace string) ClusterInterface
}
@@ -71,3 +92,42 @@ func (c *Client) ClusterNodes(namespace string) ClusterNodeInterface {
objectClient: objectClient,
}
}
type MachinesGetter interface {
Machines(namespace string) MachineInterface
}
func (c *Client) Machines(namespace string) MachineInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &MachineResource, MachineGroupVersionKind, machineFactory{})
return &machineClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type MachineDriversGetter interface {
MachineDrivers(namespace string) MachineDriverInterface
}
func (c *Client) MachineDrivers(namespace string) MachineDriverInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &MachineDriverResource, MachineDriverGroupVersionKind, machineDriverFactory{})
return &machineDriverClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type MachineTemplatesGetter interface {
MachineTemplates(namespace string) MachineTemplateInterface
}
func (c *Client) MachineTemplates(namespace string) MachineTemplateInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &MachineTemplateResource, MachineTemplateGroupVersionKind, machineTemplateFactory{})
return &machineTemplateClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@@ -0,0 +1,187 @@
package v1
import (
"context"
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
MachineGroupVersionKind = schema.GroupVersionKind{
Version: "v1",
Group: "cluster.cattle.io",
Kind: "Machine",
}
MachineResource = metav1.APIResource{
Name: "machines",
SingularName: "machine",
Namespaced: false,
Kind: MachineGroupVersionKind.Kind,
}
)
type MachineList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Machine
}
type MachineHandlerFunc func(key string, obj *Machine) error
type MachineLister interface {
List(namespace string, selector labels.Selector) (ret []*Machine, err error)
Get(namespace, name string) (*Machine, error)
}
type MachineController interface {
Informer() cache.SharedIndexInformer
Lister() MachineLister
AddHandler(handler MachineHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type MachineInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*Machine) (*Machine, error)
Get(name string, opts metav1.GetOptions) (*Machine, error)
Update(*Machine) (*Machine, error)
Delete(name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*MachineList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() MachineController
}
type machineLister struct {
controller *machineController
}
func (l *machineLister) List(namespace string, selector labels.Selector) (ret []*Machine, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*Machine))
})
return
}
func (l *machineLister) Get(namespace, name string) (*Machine, error) {
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: MachineGroupVersionKind.Group,
Resource: "machine",
}, name)
}
return obj.(*Machine), nil
}
type machineController struct {
controller.GenericController
}
func (c *machineController) Lister() MachineLister {
return &machineLister{
controller: c,
}
}
func (c *machineController) AddHandler(handler MachineHandlerFunc) {
c.GenericController.AddHandler(func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
return handler(key, obj.(*Machine))
})
}
type machineFactory struct {
}
func (c machineFactory) Object() runtime.Object {
return &Machine{}
}
func (c machineFactory) List() runtime.Object {
return &MachineList{}
}
func (s *machineClient) Controller() MachineController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.machineControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(MachineGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &machineController{
GenericController: genericController,
}
s.client.machineControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type machineClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller MachineController
}
func (s *machineClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *machineClient) Create(o *Machine) (*Machine, error) {
obj, err := s.objectClient.Create(o)
return obj.(*Machine), err
}
func (s *machineClient) Get(name string, opts metav1.GetOptions) (*Machine, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*Machine), err
}
func (s *machineClient) Update(o *Machine) (*Machine, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*Machine), err
}
func (s *machineClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *machineClient) List(opts metav1.ListOptions) (*MachineList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*MachineList), err
}
func (s *machineClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
func (s *machineClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}

View File

@@ -0,0 +1,187 @@
package v1
import (
"context"
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
MachineDriverGroupVersionKind = schema.GroupVersionKind{
Version: "v1",
Group: "cluster.cattle.io",
Kind: "MachineDriver",
}
MachineDriverResource = metav1.APIResource{
Name: "machinedrivers",
SingularName: "machinedriver",
Namespaced: false,
Kind: MachineDriverGroupVersionKind.Kind,
}
)
type MachineDriverList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MachineDriver
}
type MachineDriverHandlerFunc func(key string, obj *MachineDriver) error
type MachineDriverLister interface {
List(namespace string, selector labels.Selector) (ret []*MachineDriver, err error)
Get(namespace, name string) (*MachineDriver, error)
}
type MachineDriverController interface {
Informer() cache.SharedIndexInformer
Lister() MachineDriverLister
AddHandler(handler MachineDriverHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type MachineDriverInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*MachineDriver) (*MachineDriver, error)
Get(name string, opts metav1.GetOptions) (*MachineDriver, error)
Update(*MachineDriver) (*MachineDriver, error)
Delete(name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*MachineDriverList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() MachineDriverController
}
type machineDriverLister struct {
controller *machineDriverController
}
func (l *machineDriverLister) List(namespace string, selector labels.Selector) (ret []*MachineDriver, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*MachineDriver))
})
return
}
func (l *machineDriverLister) Get(namespace, name string) (*MachineDriver, error) {
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: MachineDriverGroupVersionKind.Group,
Resource: "machineDriver",
}, name)
}
return obj.(*MachineDriver), nil
}
type machineDriverController struct {
controller.GenericController
}
func (c *machineDriverController) Lister() MachineDriverLister {
return &machineDriverLister{
controller: c,
}
}
func (c *machineDriverController) AddHandler(handler MachineDriverHandlerFunc) {
c.GenericController.AddHandler(func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
return handler(key, obj.(*MachineDriver))
})
}
type machineDriverFactory struct {
}
func (c machineDriverFactory) Object() runtime.Object {
return &MachineDriver{}
}
func (c machineDriverFactory) List() runtime.Object {
return &MachineDriverList{}
}
func (s *machineDriverClient) Controller() MachineDriverController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.machineDriverControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(MachineDriverGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &machineDriverController{
GenericController: genericController,
}
s.client.machineDriverControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type machineDriverClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller MachineDriverController
}
func (s *machineDriverClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *machineDriverClient) Create(o *MachineDriver) (*MachineDriver, error) {
obj, err := s.objectClient.Create(o)
return obj.(*MachineDriver), err
}
func (s *machineDriverClient) Get(name string, opts metav1.GetOptions) (*MachineDriver, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*MachineDriver), err
}
func (s *machineDriverClient) Update(o *MachineDriver) (*MachineDriver, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*MachineDriver), err
}
func (s *machineDriverClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *machineDriverClient) List(opts metav1.ListOptions) (*MachineDriverList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*MachineDriverList), err
}
func (s *machineDriverClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
func (s *machineDriverClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}

View File

@@ -0,0 +1,187 @@
package v1
import (
"context"
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
MachineTemplateGroupVersionKind = schema.GroupVersionKind{
Version: "v1",
Group: "cluster.cattle.io",
Kind: "MachineTemplate",
}
MachineTemplateResource = metav1.APIResource{
Name: "machinetemplates",
SingularName: "machinetemplate",
Namespaced: false,
Kind: MachineTemplateGroupVersionKind.Kind,
}
)
type MachineTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MachineTemplate
}
type MachineTemplateHandlerFunc func(key string, obj *MachineTemplate) error
type MachineTemplateLister interface {
List(namespace string, selector labels.Selector) (ret []*MachineTemplate, err error)
Get(namespace, name string) (*MachineTemplate, error)
}
type MachineTemplateController interface {
Informer() cache.SharedIndexInformer
Lister() MachineTemplateLister
AddHandler(handler MachineTemplateHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type MachineTemplateInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*MachineTemplate) (*MachineTemplate, error)
Get(name string, opts metav1.GetOptions) (*MachineTemplate, error)
Update(*MachineTemplate) (*MachineTemplate, error)
Delete(name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*MachineTemplateList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() MachineTemplateController
}
type machineTemplateLister struct {
controller *machineTemplateController
}
func (l *machineTemplateLister) List(namespace string, selector labels.Selector) (ret []*MachineTemplate, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*MachineTemplate))
})
return
}
func (l *machineTemplateLister) Get(namespace, name string) (*MachineTemplate, error) {
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: MachineTemplateGroupVersionKind.Group,
Resource: "machineTemplate",
}, name)
}
return obj.(*MachineTemplate), nil
}
type machineTemplateController struct {
controller.GenericController
}
func (c *machineTemplateController) Lister() MachineTemplateLister {
return &machineTemplateLister{
controller: c,
}
}
func (c *machineTemplateController) AddHandler(handler MachineTemplateHandlerFunc) {
c.GenericController.AddHandler(func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
return handler(key, obj.(*MachineTemplate))
})
}
type machineTemplateFactory struct {
}
func (c machineTemplateFactory) Object() runtime.Object {
return &MachineTemplate{}
}
func (c machineTemplateFactory) List() runtime.Object {
return &MachineTemplateList{}
}
func (s *machineTemplateClient) Controller() MachineTemplateController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.machineTemplateControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(MachineTemplateGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &machineTemplateController{
GenericController: genericController,
}
s.client.machineTemplateControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type machineTemplateClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller MachineTemplateController
}
func (s *machineTemplateClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *machineTemplateClient) Create(o *MachineTemplate) (*MachineTemplate, error) {
obj, err := s.objectClient.Create(o)
return obj.(*MachineTemplate), err
}
func (s *machineTemplateClient) Get(name string, opts metav1.GetOptions) (*MachineTemplate, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*MachineTemplate), err
}
func (s *machineTemplateClient) Update(o *MachineTemplate) (*MachineTemplate, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*MachineTemplate), err
}
func (s *machineTemplateClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *machineTemplateClient) List(opts metav1.ListOptions) (*MachineTemplateList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*MachineTemplateList), err
}
func (s *machineTemplateClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
func (s *machineTemplateClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}

View File

@@ -3,4 +3,5 @@ github.com/rancher/types
k8s.io/kubernetes v1.8.3 transitive=true,staging=true
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
github.com/rancher/norman faa1fb2148211044253fc2f6403008958c72b1f0
github.com/rancher/norman 5ec6a8d719917fcca3cab8e8e9036384385ced40
golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5