From 6bb21f32af76a3f957bc973e3d655fb89f72f85a Mon Sep 17 00:00:00 2001 From: Christopher Hein Date: Wed, 28 Nov 2018 12:15:56 +0000 Subject: [PATCH] Adding code generation for non-pointer config Signed-off-by: Christopher Hein --- pkg/helpers/template_functions.go | 28 +++++++++---------- pkg/operators/base/base.go | 4 +-- .../cloudformationtemplate/operator.go | 4 +-- pkg/operators/dynamodb/cft.go | 4 +-- pkg/operators/dynamodb/operator.go | 14 +++++----- pkg/operators/ecrrepository/cft.go | 4 +-- pkg/operators/ecrrepository/operator.go | 14 +++++----- pkg/operators/s3bucket/cft.go | 4 +-- pkg/operators/s3bucket/operator.go | 14 +++++----- pkg/operators/snssubscription/cft.go | 4 +-- pkg/operators/snssubscription/operator.go | 14 +++++----- pkg/operators/snstopic/cft.go | 4 +-- pkg/operators/snstopic/operator.go | 14 +++++----- pkg/operators/sqsqueue/cft.go | 4 +-- pkg/operators/sqsqueue/operator.go | 14 +++++----- 15 files changed, 72 insertions(+), 72 deletions(-) diff --git a/pkg/helpers/template_functions.go b/pkg/helpers/template_functions.go index faa40878a..49aca43a2 100644 --- a/pkg/helpers/template_functions.go +++ b/pkg/helpers/template_functions.go @@ -28,17 +28,17 @@ func New() Helpers { // Helpers defines all the Helper functions that are exposed to the templates type Helpers struct { KubernetesResourceName func(string) string - GetCloudFormationTemplateByName func(*config.Config, string, string) (interface{}, error) - GetDynamoDBByName func(*config.Config, string, string) (interface{}, error) - GetECRRepositoryByName func(*config.Config, string, string) (interface{}, error) - GetS3BucketByName func(*config.Config, string, string) (interface{}, error) - GetSNSSubscriptionByName func(*config.Config, string, string) (interface{}, error) - GetSNSTopicByName func(*config.Config, string, string) (interface{}, error) - GetSQSQueueByName func(*config.Config, string, string) (interface{}, error) + GetCloudFormationTemplateByName func(config.Config, string, string) (interface{}, error) + GetDynamoDBByName func(config.Config, string, string) (interface{}, error) + GetECRRepositoryByName func(config.Config, string, string) (interface{}, error) + GetS3BucketByName func(config.Config, string, string) (interface{}, error) + GetSNSSubscriptionByName func(config.Config, string, string) (interface{}, error) + GetSNSTopicByName func(config.Config, string, string) (interface{}, error) + GetSQSQueueByName func(config.Config, string, string) (interface{}, error) } // GetCloudFormationTemplateByName will find the resource by name -func GetCloudFormationTemplateByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetCloudFormationTemplateByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.CloudFormationTemplates(namespace).Get(name, metav1.GetOptions{}) @@ -51,7 +51,7 @@ func GetCloudFormationTemplateByName(config *config.Config, name string, namespa } // GetDynamoDBByName will find the resource by name -func GetDynamoDBByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetDynamoDBByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{}) @@ -64,7 +64,7 @@ func GetDynamoDBByName(config *config.Config, name string, namespace string) (in } // GetECRRepositoryByName will find the resource by name -func GetECRRepositoryByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetECRRepositoryByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{}) @@ -77,7 +77,7 @@ func GetECRRepositoryByName(config *config.Config, name string, namespace string } // GetS3BucketByName will find the resource by name -func GetS3BucketByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetS3BucketByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{}) @@ -90,7 +90,7 @@ func GetS3BucketByName(config *config.Config, name string, namespace string) (in } // GetSNSSubscriptionByName will find the resource by name -func GetSNSSubscriptionByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetSNSSubscriptionByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSSubscriptions(namespace).Get(name, metav1.GetOptions{}) @@ -103,7 +103,7 @@ func GetSNSSubscriptionByName(config *config.Config, name string, namespace stri } // GetSNSTopicByName will find the resource by name -func GetSNSTopicByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetSNSTopicByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSTopics(namespace).Get(name, metav1.GetOptions{}) @@ -116,7 +116,7 @@ func GetSNSTopicByName(config *config.Config, name string, namespace string) (in } // GetSQSQueueByName will find the resource by name -func GetSQSQueueByName(config *config.Config, name string, namespace string) (interface{}, error) { +func GetSQSQueueByName(config config.Config, name string, namespace string) (interface{}, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SQSQueues(namespace).Get(name, metav1.GetOptions{}) diff --git a/pkg/operators/base/base.go b/pkg/operators/base/base.go index 154d9dc11..bed2ae27c 100644 --- a/pkg/operators/base/base.go +++ b/pkg/operators/base/base.go @@ -14,7 +14,7 @@ import ( ) type base struct { - config *config.Config + config config.Config queueManager *queuemanager.QueueManager cloudformationtemplate *cloudformationtemplate.Operator dynamodb *dynamodb.Operator @@ -26,7 +26,7 @@ type base struct { } func New( - config *config.Config, + config config.Config, queueManager *queuemanager.QueueManager, ) *base { return &base{ diff --git a/pkg/operators/cloudformationtemplate/operator.go b/pkg/operators/cloudformationtemplate/operator.go index 07f5a337c..e58123da0 100644 --- a/pkg/operators/cloudformationtemplate/operator.go +++ b/pkg/operators/cloudformationtemplate/operator.go @@ -19,13 +19,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { return &Operator{ config: config, diff --git a/pkg/operators/dynamodb/cft.go b/pkg/operators/dynamodb/cft.go index 617f6815b..d5a384457 100644 --- a/pkg/operators/dynamodb/cft.go +++ b/pkg/operators/dynamodb/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string) *Cloudformation { +func New(config config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string) *Cloudformation { return &Cloudformation{ DynamoDB: dynamodb, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string) // Cloudformation defines the dynamodb cfts type Cloudformation struct { - config *config.Config + config config.Config DynamoDB *awsV1alpha1.DynamoDB topicARN string } diff --git a/pkg/operators/dynamodb/operator.go b/pkg/operators/dynamodb/operator.go index 338ffbc26..a2c5cd879 100644 --- a/pkg/operators/dynamodb/operator.go +++ b/pkg/operators/dynamodb/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("dynamodb") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted dynamodb '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.DynamoDB, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.DynamoDB, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{}) @@ -226,7 +226,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.DynamoDB, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.DynamoDB, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{}) @@ -245,7 +245,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.DynamoDB) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.DynamoDB) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.DynamoDBs(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/operators/ecrrepository/cft.go b/pkg/operators/ecrrepository/cft.go index 301f2b378..926914297 100644 --- a/pkg/operators/ecrrepository/cft.go +++ b/pkg/operators/ecrrepository/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicARN string) *Cloudformation { +func New(config config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicARN string) *Cloudformation { return &Cloudformation{ ECRRepository: ecrrepository, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicA // Cloudformation defines the ecrrepository cfts type Cloudformation struct { - config *config.Config + config config.Config ECRRepository *awsV1alpha1.ECRRepository topicARN string } diff --git a/pkg/operators/ecrrepository/operator.go b/pkg/operators/ecrrepository/operator.go index 3d753aaee..195e4834f 100644 --- a/pkg/operators/ecrrepository/operator.go +++ b/pkg/operators/ecrrepository/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("ecrrepository") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted ecrrepository '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.ECRRepository, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.ECRRepository, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{}) @@ -228,7 +228,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.ECRRepository, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.ECRRepository, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{}) @@ -247,7 +247,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.ECRRepository) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.ECRRepository) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.ECRRepositories(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/operators/s3bucket/cft.go b/pkg/operators/s3bucket/cft.go index 77035f0b7..0a14815f5 100644 --- a/pkg/operators/s3bucket/cft.go +++ b/pkg/operators/s3bucket/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string) *Cloudformation { +func New(config config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string) *Cloudformation { return &Cloudformation{ S3Bucket: s3bucket, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string) // Cloudformation defines the s3bucket cfts type Cloudformation struct { - config *config.Config + config config.Config S3Bucket *awsV1alpha1.S3Bucket topicARN string } diff --git a/pkg/operators/s3bucket/operator.go b/pkg/operators/s3bucket/operator.go index fbb770423..744366cba 100644 --- a/pkg/operators/s3bucket/operator.go +++ b/pkg/operators/s3bucket/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("s3bucket") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted s3bucket '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.S3Bucket, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.S3Bucket, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{}) @@ -227,7 +227,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.S3Bucket, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.S3Bucket, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{}) @@ -246,7 +246,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.S3Bucket) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.S3Bucket) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.S3Buckets(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/operators/snssubscription/cft.go b/pkg/operators/snssubscription/cft.go index 5497b9821..3c8ee0df7 100644 --- a/pkg/operators/snssubscription/cft.go +++ b/pkg/operators/snssubscription/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, snssubscription *awsV1alpha1.SNSSubscription, topicARN string) *Cloudformation { +func New(config config.Config, snssubscription *awsV1alpha1.SNSSubscription, topicARN string) *Cloudformation { return &Cloudformation{ SNSSubscription: snssubscription, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, snssubscription *awsV1alpha1.SNSSubscription, to // Cloudformation defines the snssubscription cfts type Cloudformation struct { - config *config.Config + config config.Config SNSSubscription *awsV1alpha1.SNSSubscription topicARN string } diff --git a/pkg/operators/snssubscription/operator.go b/pkg/operators/snssubscription/operator.go index fb4e2d13c..067f46599 100644 --- a/pkg/operators/snssubscription/operator.go +++ b/pkg/operators/snssubscription/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("snssubscription") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted snssubscription '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSSubscriptions(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SNSSubscription, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SNSSubscription, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSSubscriptions(namespace).Get(name, metav1.GetOptions{}) @@ -225,7 +225,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SNSSubscription, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SNSSubscription, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSSubscriptions(namespace).Get(name, metav1.GetOptions{}) @@ -244,7 +244,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.SNSSubscription) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.SNSSubscription) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSSubscriptions(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/operators/snstopic/cft.go b/pkg/operators/snstopic/cft.go index e2fd46527..5e04c2395 100644 --- a/pkg/operators/snstopic/cft.go +++ b/pkg/operators/snstopic/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, snstopic *awsV1alpha1.SNSTopic, topicARN string) *Cloudformation { +func New(config config.Config, snstopic *awsV1alpha1.SNSTopic, topicARN string) *Cloudformation { return &Cloudformation{ SNSTopic: snstopic, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, snstopic *awsV1alpha1.SNSTopic, topicARN string) // Cloudformation defines the snstopic cfts type Cloudformation struct { - config *config.Config + config config.Config SNSTopic *awsV1alpha1.SNSTopic topicARN string } diff --git a/pkg/operators/snstopic/operator.go b/pkg/operators/snstopic/operator.go index d6218498d..6f67bacff 100644 --- a/pkg/operators/snstopic/operator.go +++ b/pkg/operators/snstopic/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("snstopic") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted snstopic '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSTopics(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SNSTopic, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SNSTopic, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSTopics(namespace).Get(name, metav1.GetOptions{}) @@ -225,7 +225,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SNSTopic, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SNSTopic, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSTopics(namespace).Get(name, metav1.GetOptions{}) @@ -244,7 +244,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.SNSTopic) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.SNSTopic) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SNSTopics(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/operators/sqsqueue/cft.go b/pkg/operators/sqsqueue/cft.go index 9ee0580fd..fdd261a9a 100644 --- a/pkg/operators/sqsqueue/cft.go +++ b/pkg/operators/sqsqueue/cft.go @@ -15,7 +15,7 @@ import ( ) // New generates a new object -func New(config *config.Config, sqsqueue *awsV1alpha1.SQSQueue, topicARN string) *Cloudformation { +func New(config config.Config, sqsqueue *awsV1alpha1.SQSQueue, topicARN string) *Cloudformation { return &Cloudformation{ SQSQueue: sqsqueue, config: config, @@ -25,7 +25,7 @@ func New(config *config.Config, sqsqueue *awsV1alpha1.SQSQueue, topicARN string) // Cloudformation defines the sqsqueue cfts type Cloudformation struct { - config *config.Config + config config.Config SQSQueue *awsV1alpha1.SQSQueue topicARN string } diff --git a/pkg/operators/sqsqueue/operator.go b/pkg/operators/sqsqueue/operator.go index 339dc4c3c..2f1c49816 100644 --- a/pkg/operators/sqsqueue/operator.go +++ b/pkg/operators/sqsqueue/operator.go @@ -26,13 +26,13 @@ import ( // Operator represents a controller object for object store custom resources type Operator struct { - config *config.Config + config config.Config topicARN string queueManager *queuemanager.QueueManager } // NewOperator create controller for watching object store custom resources created -func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator { +func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator { queuectrl := queue.New(config, config.AWSClientset, 10) topicARN, _ := queuectrl.Register("sqsqueue") queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater)) @@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) { } // QueueUpdater will take the messages from the queue and process them -func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error { +func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error { logger := config.Logger var name, namespace string if msg.Updatable { @@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) { c.config.Logger.Infof("deleted sqsqueue '%s'", s.Name) } -func incrementRollbackCount(config *config.Config, name string, namespace string) error { +func incrementRollbackCount(config config.Config, name string, namespace string) error { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SQSQueues(namespace).Get(name, metav1.GetOptions{}) @@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string return nil } -func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SQSQueue, error) { +func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.SQSQueue, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SQSQueues(namespace).Get(name, metav1.GetOptions{}) @@ -230,7 +230,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID return resourceCopy, nil } -func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SQSQueue, error) { +func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.SQSQueue, error) { logger := config.Logger clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SQSQueues(namespace).Get(name, metav1.GetOptions{}) @@ -249,7 +249,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s return resource, err } -func syncAdditionalResources(config *config.Config, s *awsV1alpha1.SQSQueue) (err error) { +func syncAdditionalResources(config config.Config, s *awsV1alpha1.SQSQueue) (err error) { clientSet, _ := awsclient.NewForConfig(config.RESTConfig) resource, err := clientSet.SQSQueues(s.Namespace).Get(s.Name, metav1.GetOptions{}) if err != nil {