From daa0ac6216ff7261e159ed34be64b76d671d1674 Mon Sep 17 00:00:00 2001 From: Christopher Hein Date: Tue, 16 Oct 2018 06:51:19 +0000 Subject: [PATCH] Adding Generated Code for Removing Operator Kit Signed-off-by: Christopher Hein --- pkg/operators/base/base.go | 82 ++++++++++--------- .../cloudformationtemplate/operator.go | 41 ++-------- pkg/operators/dynamodb/operator.go | 42 ++-------- pkg/operators/ecrrepository/operator.go | 39 ++------- pkg/operators/s3bucket/operator.go | 40 ++------- pkg/operators/snssubscription/operator.go | 38 ++------- pkg/operators/snstopic/operator.go | 40 ++------- pkg/operators/sqsqueue/operator.go | 40 ++------- 8 files changed, 105 insertions(+), 257 deletions(-) diff --git a/pkg/operators/base/base.go b/pkg/operators/base/base.go index 419a46405..88c72c39b 100644 --- a/pkg/operators/base/base.go +++ b/pkg/operators/base/base.go @@ -1,7 +1,6 @@ package base import ( - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" "github.com/awslabs/aws-service-operator/pkg/operators/cloudformationtemplate" "github.com/awslabs/aws-service-operator/pkg/operators/dynamodb" @@ -10,62 +9,69 @@ import ( "github.com/awslabs/aws-service-operator/pkg/operators/snssubscription" "github.com/awslabs/aws-service-operator/pkg/operators/snstopic" "github.com/awslabs/aws-service-operator/pkg/operators/sqsqueue" - opkit "github.com/christopherhein/operator-kit" ) type base struct { - config *config.Config - context *opkit.Context - awsClientset awsclient.ServiceoperatorV1alpha1Interface + config *config.Config } func New( config *config.Config, - context *opkit.Context, - awsClientset awsclient.ServiceoperatorV1alpha1Interface, ) *base { return &base{ - config: config, - context: context, - awsClientset: awsClientset, + config: config, } } func (b *base) Watch(namespace string, stopCh chan struct{}) (err error) { - cloudformationtemplateoperator := cloudformationtemplate.NewOperator(b.config, b.context, b.awsClientset) - err = cloudformationtemplateoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["cloudformationtemplate"] { + cloudformationtemplateoperator := cloudformationtemplate.NewOperator(b.config) + err = cloudformationtemplateoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - dynamodboperator := dynamodb.NewOperator(b.config, b.context, b.awsClientset) - err = dynamodboperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["dynamodb"] { + dynamodboperator := dynamodb.NewOperator(b.config) + err = dynamodboperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - ecrrepositoryoperator := ecrrepository.NewOperator(b.config, b.context, b.awsClientset) - err = ecrrepositoryoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["ecrrepository"] { + ecrrepositoryoperator := ecrrepository.NewOperator(b.config) + err = ecrrepositoryoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - s3bucketoperator := s3bucket.NewOperator(b.config, b.context, b.awsClientset) - err = s3bucketoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["s3bucket"] { + s3bucketoperator := s3bucket.NewOperator(b.config) + err = s3bucketoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - snssubscriptionoperator := snssubscription.NewOperator(b.config, b.context, b.awsClientset) - err = snssubscriptionoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["snssubscription"] { + snssubscriptionoperator := snssubscription.NewOperator(b.config) + err = snssubscriptionoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - snstopicoperator := snstopic.NewOperator(b.config, b.context, b.awsClientset) - err = snstopicoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["snstopic"] { + snstopicoperator := snstopic.NewOperator(b.config) + err = snstopicoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } - sqsqueueoperator := sqsqueue.NewOperator(b.config, b.context, b.awsClientset) - err = sqsqueueoperator.StartWatch(namespace, stopCh) - if err != nil { - return err + if b.config.Resources["sqsqueue"] { + sqsqueueoperator := sqsqueue.NewOperator(b.config) + err = sqsqueueoperator.StartWatch(namespace, stopCh) + if err != nil { + return err + } } return nil diff --git a/pkg/operators/cloudformationtemplate/operator.go b/pkg/operators/cloudformationtemplate/operator.go index ec329eff4..a2e9a76db 100644 --- a/pkg/operators/cloudformationtemplate/operator.go +++ b/pkg/operators/cloudformationtemplate/operator.go @@ -6,50 +6,24 @@ package cloudformationtemplate import ( - "reflect" - "github.com/awslabs/aws-service-operator/pkg/config" - opkit "github.com/christopherhein/operator-kit" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "github.com/awslabs/aws-service-operator/pkg/operator" "k8s.io/client-go/tools/cache" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/customizations/cloudformationtemplate" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "cloudformationtemplate", - Plural: "cloudformationtemplates", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.CloudFormationTemplate{}).Name(), - ShortNames: []string{ - "cft", - "cfts", - "cfn", - "cfns", - "cloudformation", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -61,9 +35,8 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { DeleteFunc: c.onDelete, } - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.CloudFormationTemplate{}, stopCh) + oper := operator.New("cloudformationtemplates", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.CloudFormationTemplate{}, stopCh) return nil } diff --git a/pkg/operators/dynamodb/operator.go b/pkg/operators/dynamodb/operator.go index 52b36118f..3614bef1a 100644 --- a/pkg/operators/dynamodb/operator.go +++ b/pkg/operators/dynamodb/operator.go @@ -10,51 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "dynamodb", - Plural: "dynamodbs", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.DynamoDB{}).Name(), - ShortNames: []string{ - "ddb", - "ddbs", - "dynamo", - "dynamotable", - "dynamotables", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -65,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("dynamodb", &awsV1alpha1.DynamoDB{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.DynamoDB{}, stopCh) + oper := operator.New("dynamodbs", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.DynamoDB{}, stopCh) return nil } diff --git a/pkg/operators/ecrrepository/operator.go b/pkg/operators/ecrrepository/operator.go index 878c59406..49f81a083 100644 --- a/pkg/operators/ecrrepository/operator.go +++ b/pkg/operators/ecrrepository/operator.go @@ -10,48 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "ecrrepository", - Plural: "ecrrepositories", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.ECRRepository{}).Name(), - ShortNames: []string{ - "ecr", - "repository", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -62,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("ecrrepository", &awsV1alpha1.ECRRepository{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.ECRRepository{}, stopCh) + oper := operator.New("ecrrepositories", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.ECRRepository{}, stopCh) return nil } diff --git a/pkg/operators/s3bucket/operator.go b/pkg/operators/s3bucket/operator.go index 255eed7dd..886d663ff 100644 --- a/pkg/operators/s3bucket/operator.go +++ b/pkg/operators/s3bucket/operator.go @@ -10,49 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "s3bucket", - Plural: "s3buckets", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.S3Bucket{}).Name(), - ShortNames: []string{ - "s3", - "bucket", - "buckets", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -63,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("s3bucket", &awsV1alpha1.S3Bucket{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.S3Bucket{}, stopCh) + oper := operator.New("s3buckets", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.S3Bucket{}, stopCh) return nil } diff --git a/pkg/operators/snssubscription/operator.go b/pkg/operators/snssubscription/operator.go index 6dd64c127..d7dfad927 100644 --- a/pkg/operators/snssubscription/operator.go +++ b/pkg/operators/snssubscription/operator.go @@ -10,47 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "snssubscription", - Plural: "snssubscriptions", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.SNSSubscription{}).Name(), - ShortNames: []string{ - "subscription", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -61,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("snssubscription", &awsV1alpha1.SNSSubscription{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.SNSSubscription{}, stopCh) + oper := operator.New("snssubscriptions", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.SNSSubscription{}, stopCh) return nil } diff --git a/pkg/operators/snstopic/operator.go b/pkg/operators/snstopic/operator.go index c89ab99d6..e2e47bc45 100644 --- a/pkg/operators/snstopic/operator.go +++ b/pkg/operators/snstopic/operator.go @@ -10,49 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "snstopic", - Plural: "snstopics", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.SNSTopic{}).Name(), - ShortNames: []string{ - "sns", - "topic", - "topics", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -63,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("snstopic", &awsV1alpha1.SNSTopic{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.SNSTopic{}, stopCh) + oper := operator.New("snstopics", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.SNSTopic{}, stopCh) return nil } diff --git a/pkg/operators/sqsqueue/operator.go b/pkg/operators/sqsqueue/operator.go index 98c4686fd..4c1f5dfe8 100644 --- a/pkg/operators/sqsqueue/operator.go +++ b/pkg/operators/sqsqueue/operator.go @@ -10,49 +10,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" + awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" "github.com/awslabs/aws-service-operator/pkg/config" + "github.com/awslabs/aws-service-operator/pkg/operator" "github.com/awslabs/aws-service-operator/pkg/queue" - opkit "github.com/christopherhein/operator-kit" "github.com/iancoleman/strcase" corev1 "k8s.io/api/core/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/client-go/tools/cache" "strings" - awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws" awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1" - awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1" ) -// Resource is the object store definition -var Resource = opkit.CustomResource{ - Name: "sqsqueue", - Plural: "sqsqueues", - Group: awsapi.GroupName, - Version: awsapi.Version, - Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(awsV1alpha1.SQSQueue{}).Name(), - ShortNames: []string{ - "sqs", - "queue", - "queues", - }, -} - // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config - context *opkit.Context - awsclientset awsclient.ServiceoperatorV1alpha1Interface - topicARN string + config *config.Config + topicARN string } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator { +func NewOperator(config *config.Config) *Operator { return &Operator{ - config: config, - context: context, - awsclientset: awsclientset, + config: config, } } @@ -63,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error { UpdateFunc: c.onUpdate, DeleteFunc: c.onDelete, } - queuectrl := queue.New(c.config, c.context, c.awsclientset, 1) + queuectrl := queue.New(c.config, c.config.AWSClientset, 1) c.topicARN, _, _, _ = queuectrl.Register("sqsqueue", &awsV1alpha1.SQSQueue{}) go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh) - restClient := c.awsclientset.RESTClient() - watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient) - go watcher.Watch(&awsV1alpha1.SQSQueue{}, stopCh) + oper := operator.New("sqsqueues", namespace, resourceHandlers, c.config.AWSClientset.RESTClient()) + go oper.Watch(&awsV1alpha1.SQSQueue{}, stopCh) return nil }