mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 06:56:29 +00:00
Vendor update
This commit is contained in:
1
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
1
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
@@ -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).
|
||||
|
64
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
64
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
@@ -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
40
vendor/github.com/rancher/norman/controller/starter.go
generated
vendored
Normal 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
|
||||
}
|
19
vendor/github.com/rancher/norman/types/definition/definition.go
generated
vendored
19
vendor/github.com/rancher/norman/types/definition/definition.go
generated
vendored
@@ -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"])
|
||||
}
|
||||
|
6
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
6
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
@@ -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 {
|
||||
|
12
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
12
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
@@ -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 {
|
||||
|
8
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
8
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
2
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
2
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
@@ -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)
|
||||
}
|
||||
|
2
vendor/github.com/rancher/norman/types/types.go
generated
vendored
2
vendor/github.com/rancher/norman/types/types.go
generated
vendored
@@ -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"`
|
||||
|
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
@@ -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 object’s 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 object’s 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 object’s 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 object’s 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"`
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
518
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
518
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
68
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_k8s_client.go
generated
vendored
68
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_k8s_client.go
generated
vendored
@@ -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,
|
||||
}
|
||||
}
|
||||
|
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_controller.go
generated
vendored
Normal file
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_controller.go
generated
vendored
Normal 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)
|
||||
}
|
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_driver_controller.go
generated
vendored
Normal file
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_driver_controller.go
generated
vendored
Normal 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)
|
||||
}
|
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_template_controller.go
generated
vendored
Normal file
187
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_machine_template_controller.go
generated
vendored
Normal 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)
|
||||
}
|
3
vendor/github.com/rancher/types/vendor.conf
generated
vendored
3
vendor/github.com/rancher/types/vendor.conf
generated
vendored
@@ -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
|
||||
|
3
vendor/golang.org/x/sync/AUTHORS
generated
vendored
Normal file
3
vendor/golang.org/x/sync/AUTHORS
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# This source code refers to The Go Authors for copyright purposes.
|
||||
# The master list of authors is in the main Go distribution,
|
||||
# visible at http://tip.golang.org/AUTHORS.
|
31
vendor/golang.org/x/sync/CONTRIBUTING.md
generated
vendored
Normal file
31
vendor/golang.org/x/sync/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Contributing to Go
|
||||
|
||||
Go is an open source project.
|
||||
|
||||
It is the work of hundreds of contributors. We appreciate your help!
|
||||
|
||||
|
||||
## Filing issues
|
||||
|
||||
When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions:
|
||||
|
||||
1. What version of Go are you using (`go version`)?
|
||||
2. What operating system and processor architecture are you using?
|
||||
3. What did you do?
|
||||
4. What did you expect to see?
|
||||
5. What did you see instead?
|
||||
|
||||
General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.
|
||||
The gophers there will answer or ask you to file an issue if you've tripped over a bug.
|
||||
|
||||
## Contributing code
|
||||
|
||||
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
|
||||
before sending patches.
|
||||
|
||||
**We do not accept GitHub pull requests**
|
||||
(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review).
|
||||
|
||||
Unless otherwise noted, the Go source files are distributed under
|
||||
the BSD-style license found in the LICENSE file.
|
||||
|
3
vendor/golang.org/x/sync/CONTRIBUTORS
generated
vendored
Normal file
3
vendor/golang.org/x/sync/CONTRIBUTORS
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# This source code was written by the Go contributors.
|
||||
# The master list of contributors is in the main Go distribution,
|
||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
27
vendor/golang.org/x/sync/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/sync/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/golang.org/x/sync/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/sync/PATENTS
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Additional IP Rights Grant (Patents)
|
||||
|
||||
"This implementation" means the copyrightable works distributed by
|
||||
Google as part of the Go project.
|
||||
|
||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||
patent license to make, have made, use, offer to sell, sell, import,
|
||||
transfer and otherwise run, modify and propagate the contents of this
|
||||
implementation of Go, where such license applies only to those patent
|
||||
claims, both currently owned or controlled by Google and acquired in
|
||||
the future, licensable by Google that are necessarily infringed by this
|
||||
implementation of Go. This grant does not include claims that would be
|
||||
infringed only as a consequence of further modification of this
|
||||
implementation. If you or your agent or exclusive licensee institute or
|
||||
order or agree to the institution of patent litigation against any
|
||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that this implementation of Go or any code incorporated within this
|
||||
implementation of Go constitutes direct or contributory patent
|
||||
infringement, or inducement of patent infringement, then any patent
|
||||
rights granted to you under this License for this implementation of Go
|
||||
shall terminate as of the date such litigation is filed.
|
18
vendor/golang.org/x/sync/README.md
generated
vendored
Normal file
18
vendor/golang.org/x/sync/README.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Go Sync
|
||||
|
||||
This repository provides Go concurrency primitives in addition to the
|
||||
ones provided by the language and "sync" and "sync/atomic" packages.
|
||||
|
||||
## Download/Install
|
||||
|
||||
The easiest way to install is to run `go get -u golang.org/x/sync`. You can
|
||||
also manually git clone the repository to `$GOPATH/src/golang.org/x/sync`.
|
||||
|
||||
## Report Issues / Send Patches
|
||||
|
||||
This repository uses Gerrit for code changes. To learn how to submit changes to
|
||||
this repository, see https://golang.org/doc/contribute.html.
|
||||
|
||||
The main issue tracker for the sync repository is located at
|
||||
https://github.com/golang/go/issues. Prefix your issue with "x/sync:" in the
|
||||
subject line, so it is easy to find.
|
1
vendor/golang.org/x/sync/codereview.cfg
generated
vendored
Normal file
1
vendor/golang.org/x/sync/codereview.cfg
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
issuerepo: golang/go
|
67
vendor/golang.org/x/sync/errgroup/errgroup.go
generated
vendored
Normal file
67
vendor/golang.org/x/sync/errgroup/errgroup.go
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package errgroup provides synchronization, error propagation, and Context
|
||||
// cancelation for groups of goroutines working on subtasks of a common task.
|
||||
package errgroup
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// A Group is a collection of goroutines working on subtasks that are part of
|
||||
// the same overall task.
|
||||
//
|
||||
// A zero Group is valid and does not cancel on error.
|
||||
type Group struct {
|
||||
cancel func()
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
||||
errOnce sync.Once
|
||||
err error
|
||||
}
|
||||
|
||||
// WithContext returns a new Group and an associated Context derived from ctx.
|
||||
//
|
||||
// The derived Context is canceled the first time a function passed to Go
|
||||
// returns a non-nil error or the first time Wait returns, whichever occurs
|
||||
// first.
|
||||
func WithContext(ctx context.Context) (*Group, context.Context) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
return &Group{cancel: cancel}, ctx
|
||||
}
|
||||
|
||||
// Wait blocks until all function calls from the Go method have returned, then
|
||||
// returns the first non-nil error (if any) from them.
|
||||
func (g *Group) Wait() error {
|
||||
g.wg.Wait()
|
||||
if g.cancel != nil {
|
||||
g.cancel()
|
||||
}
|
||||
return g.err
|
||||
}
|
||||
|
||||
// Go calls the given function in a new goroutine.
|
||||
//
|
||||
// The first call to return a non-nil error cancels the group; its error will be
|
||||
// returned by Wait.
|
||||
func (g *Group) Go(f func() error) {
|
||||
g.wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer g.wg.Done()
|
||||
|
||||
if err := f(); err != nil {
|
||||
g.errOnce.Do(func() {
|
||||
g.err = err
|
||||
if g.cancel != nil {
|
||||
g.cancel()
|
||||
}
|
||||
})
|
||||
}
|
||||
}()
|
||||
}
|
Reference in New Issue
Block a user