Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 6bb21f3

Browse files
Adding code generation for non-pointer config
Signed-off-by: Christopher Hein <[email protected]>
1 parent 98c4c6b commit 6bb21f3

File tree

15 files changed

+72
-72
lines changed

15 files changed

+72
-72
lines changed

pkg/helpers/template_functions.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ func New() Helpers {
2828
// Helpers defines all the Helper functions that are exposed to the templates
2929
type Helpers struct {
3030
KubernetesResourceName func(string) string
31-
GetCloudFormationTemplateByName func(*config.Config, string, string) (interface{}, error)
32-
GetDynamoDBByName func(*config.Config, string, string) (interface{}, error)
33-
GetECRRepositoryByName func(*config.Config, string, string) (interface{}, error)
34-
GetS3BucketByName func(*config.Config, string, string) (interface{}, error)
35-
GetSNSSubscriptionByName func(*config.Config, string, string) (interface{}, error)
36-
GetSNSTopicByName func(*config.Config, string, string) (interface{}, error)
37-
GetSQSQueueByName func(*config.Config, string, string) (interface{}, error)
31+
GetCloudFormationTemplateByName func(config.Config, string, string) (interface{}, error)
32+
GetDynamoDBByName func(config.Config, string, string) (interface{}, error)
33+
GetECRRepositoryByName func(config.Config, string, string) (interface{}, error)
34+
GetS3BucketByName func(config.Config, string, string) (interface{}, error)
35+
GetSNSSubscriptionByName func(config.Config, string, string) (interface{}, error)
36+
GetSNSTopicByName func(config.Config, string, string) (interface{}, error)
37+
GetSQSQueueByName func(config.Config, string, string) (interface{}, error)
3838
}
3939

4040
// GetCloudFormationTemplateByName will find the resource by name
41-
func GetCloudFormationTemplateByName(config *config.Config, name string, namespace string) (interface{}, error) {
41+
func GetCloudFormationTemplateByName(config config.Config, name string, namespace string) (interface{}, error) {
4242
logger := config.Logger
4343
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
4444
resource, err := clientSet.CloudFormationTemplates(namespace).Get(name, metav1.GetOptions{})
@@ -51,7 +51,7 @@ func GetCloudFormationTemplateByName(config *config.Config, name string, namespa
5151
}
5252

5353
// GetDynamoDBByName will find the resource by name
54-
func GetDynamoDBByName(config *config.Config, name string, namespace string) (interface{}, error) {
54+
func GetDynamoDBByName(config config.Config, name string, namespace string) (interface{}, error) {
5555
logger := config.Logger
5656
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
5757
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
@@ -64,7 +64,7 @@ func GetDynamoDBByName(config *config.Config, name string, namespace string) (in
6464
}
6565

6666
// GetECRRepositoryByName will find the resource by name
67-
func GetECRRepositoryByName(config *config.Config, name string, namespace string) (interface{}, error) {
67+
func GetECRRepositoryByName(config config.Config, name string, namespace string) (interface{}, error) {
6868
logger := config.Logger
6969
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
7070
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
@@ -77,7 +77,7 @@ func GetECRRepositoryByName(config *config.Config, name string, namespace string
7777
}
7878

7979
// GetS3BucketByName will find the resource by name
80-
func GetS3BucketByName(config *config.Config, name string, namespace string) (interface{}, error) {
80+
func GetS3BucketByName(config config.Config, name string, namespace string) (interface{}, error) {
8181
logger := config.Logger
8282
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
8383
resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{})
@@ -90,7 +90,7 @@ func GetS3BucketByName(config *config.Config, name string, namespace string) (in
9090
}
9191

9292
// GetSNSSubscriptionByName will find the resource by name
93-
func GetSNSSubscriptionByName(config *config.Config, name string, namespace string) (interface{}, error) {
93+
func GetSNSSubscriptionByName(config config.Config, name string, namespace string) (interface{}, error) {
9494
logger := config.Logger
9595
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
9696
resource, err := clientSet.SNSSubscriptions(namespace).Get(name, metav1.GetOptions{})
@@ -103,7 +103,7 @@ func GetSNSSubscriptionByName(config *config.Config, name string, namespace stri
103103
}
104104

105105
// GetSNSTopicByName will find the resource by name
106-
func GetSNSTopicByName(config *config.Config, name string, namespace string) (interface{}, error) {
106+
func GetSNSTopicByName(config config.Config, name string, namespace string) (interface{}, error) {
107107
logger := config.Logger
108108
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
109109
resource, err := clientSet.SNSTopics(namespace).Get(name, metav1.GetOptions{})
@@ -116,7 +116,7 @@ func GetSNSTopicByName(config *config.Config, name string, namespace string) (in
116116
}
117117

118118
// GetSQSQueueByName will find the resource by name
119-
func GetSQSQueueByName(config *config.Config, name string, namespace string) (interface{}, error) {
119+
func GetSQSQueueByName(config config.Config, name string, namespace string) (interface{}, error) {
120120
logger := config.Logger
121121
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
122122
resource, err := clientSet.SQSQueues(namespace).Get(name, metav1.GetOptions{})

pkg/operators/base/base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
type base struct {
17-
config *config.Config
17+
config config.Config
1818
queueManager *queuemanager.QueueManager
1919
cloudformationtemplate *cloudformationtemplate.Operator
2020
dynamodb *dynamodb.Operator
@@ -26,7 +26,7 @@ type base struct {
2626
}
2727

2828
func New(
29-
config *config.Config,
29+
config config.Config,
3030
queueManager *queuemanager.QueueManager,
3131
) *base {
3232
return &base{

pkg/operators/cloudformationtemplate/operator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import (
1919

2020
// Operator represents a controller object for object store custom resources
2121
type Operator struct {
22-
config *config.Config
22+
config config.Config
2323
topicARN string
2424
queueManager *queuemanager.QueueManager
2525
}
2626

2727
// NewOperator create controller for watching object store custom resources created
28-
func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator {
28+
func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator {
2929

3030
return &Operator{
3131
config: config,

pkg/operators/dynamodb/cft.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// New generates a new object
18-
func New(config *config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string) *Cloudformation {
18+
func New(config config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string) *Cloudformation {
1919
return &Cloudformation{
2020
DynamoDB: dynamodb,
2121
config: config,
@@ -25,7 +25,7 @@ func New(config *config.Config, dynamodb *awsV1alpha1.DynamoDB, topicARN string)
2525

2626
// Cloudformation defines the dynamodb cfts
2727
type Cloudformation struct {
28-
config *config.Config
28+
config config.Config
2929
DynamoDB *awsV1alpha1.DynamoDB
3030
topicARN string
3131
}

pkg/operators/dynamodb/operator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626

2727
// Operator represents a controller object for object store custom resources
2828
type Operator struct {
29-
config *config.Config
29+
config config.Config
3030
topicARN string
3131
queueManager *queuemanager.QueueManager
3232
}
3333

3434
// NewOperator create controller for watching object store custom resources created
35-
func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator {
35+
func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator {
3636
queuectrl := queue.New(config, config.AWSClientset, 10)
3737
topicARN, _ := queuectrl.Register("dynamodb")
3838
queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater))
@@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) {
5757
}
5858

5959
// QueueUpdater will take the messages from the queue and process them
60-
func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error {
60+
func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error {
6161
logger := config.Logger
6262
var name, namespace string
6363
if msg.Updatable {
@@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) {
167167

168168
c.config.Logger.Infof("deleted dynamodb '%s'", s.Name)
169169
}
170-
func incrementRollbackCount(config *config.Config, name string, namespace string) error {
170+
func incrementRollbackCount(config config.Config, name string, namespace string) error {
171171
logger := config.Logger
172172
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
173173
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
@@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string
187187
return nil
188188
}
189189

190-
func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.DynamoDB, error) {
190+
func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.DynamoDB, error) {
191191
logger := config.Logger
192192
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
193193
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
@@ -226,7 +226,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
226226
return resourceCopy, nil
227227
}
228228

229-
func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.DynamoDB, error) {
229+
func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.DynamoDB, error) {
230230
logger := config.Logger
231231
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
232232
resource, err := clientSet.DynamoDBs(namespace).Get(name, metav1.GetOptions{})
@@ -245,7 +245,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s
245245
return resource, err
246246
}
247247

248-
func syncAdditionalResources(config *config.Config, s *awsV1alpha1.DynamoDB) (err error) {
248+
func syncAdditionalResources(config config.Config, s *awsV1alpha1.DynamoDB) (err error) {
249249
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
250250
resource, err := clientSet.DynamoDBs(s.Namespace).Get(s.Name, metav1.GetOptions{})
251251
if err != nil {

pkg/operators/ecrrepository/cft.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// New generates a new object
18-
func New(config *config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicARN string) *Cloudformation {
18+
func New(config config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicARN string) *Cloudformation {
1919
return &Cloudformation{
2020
ECRRepository: ecrrepository,
2121
config: config,
@@ -25,7 +25,7 @@ func New(config *config.Config, ecrrepository *awsV1alpha1.ECRRepository, topicA
2525

2626
// Cloudformation defines the ecrrepository cfts
2727
type Cloudformation struct {
28-
config *config.Config
28+
config config.Config
2929
ECRRepository *awsV1alpha1.ECRRepository
3030
topicARN string
3131
}

pkg/operators/ecrrepository/operator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626

2727
// Operator represents a controller object for object store custom resources
2828
type Operator struct {
29-
config *config.Config
29+
config config.Config
3030
topicARN string
3131
queueManager *queuemanager.QueueManager
3232
}
3333

3434
// NewOperator create controller for watching object store custom resources created
35-
func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator {
35+
func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator {
3636
queuectrl := queue.New(config, config.AWSClientset, 10)
3737
topicARN, _ := queuectrl.Register("ecrrepository")
3838
queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater))
@@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) {
5757
}
5858

5959
// QueueUpdater will take the messages from the queue and process them
60-
func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error {
60+
func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error {
6161
logger := config.Logger
6262
var name, namespace string
6363
if msg.Updatable {
@@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) {
167167

168168
c.config.Logger.Infof("deleted ecrrepository '%s'", s.Name)
169169
}
170-
func incrementRollbackCount(config *config.Config, name string, namespace string) error {
170+
func incrementRollbackCount(config config.Config, name string, namespace string) error {
171171
logger := config.Logger
172172
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
173173
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
@@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string
187187
return nil
188188
}
189189

190-
func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.ECRRepository, error) {
190+
func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.ECRRepository, error) {
191191
logger := config.Logger
192192
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
193193
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
@@ -228,7 +228,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
228228
return resourceCopy, nil
229229
}
230230

231-
func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.ECRRepository, error) {
231+
func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.ECRRepository, error) {
232232
logger := config.Logger
233233
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
234234
resource, err := clientSet.ECRRepositories(namespace).Get(name, metav1.GetOptions{})
@@ -247,7 +247,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s
247247
return resource, err
248248
}
249249

250-
func syncAdditionalResources(config *config.Config, s *awsV1alpha1.ECRRepository) (err error) {
250+
func syncAdditionalResources(config config.Config, s *awsV1alpha1.ECRRepository) (err error) {
251251
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
252252
resource, err := clientSet.ECRRepositories(s.Namespace).Get(s.Name, metav1.GetOptions{})
253253
if err != nil {

pkg/operators/s3bucket/cft.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// New generates a new object
18-
func New(config *config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string) *Cloudformation {
18+
func New(config config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string) *Cloudformation {
1919
return &Cloudformation{
2020
S3Bucket: s3bucket,
2121
config: config,
@@ -25,7 +25,7 @@ func New(config *config.Config, s3bucket *awsV1alpha1.S3Bucket, topicARN string)
2525

2626
// Cloudformation defines the s3bucket cfts
2727
type Cloudformation struct {
28-
config *config.Config
28+
config config.Config
2929
S3Bucket *awsV1alpha1.S3Bucket
3030
topicARN string
3131
}

pkg/operators/s3bucket/operator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626

2727
// Operator represents a controller object for object store custom resources
2828
type Operator struct {
29-
config *config.Config
29+
config config.Config
3030
topicARN string
3131
queueManager *queuemanager.QueueManager
3232
}
3333

3434
// NewOperator create controller for watching object store custom resources created
35-
func NewOperator(config *config.Config, queueManager *queuemanager.QueueManager) *Operator {
35+
func NewOperator(config config.Config, queueManager *queuemanager.QueueManager) *Operator {
3636
queuectrl := queue.New(config, config.AWSClientset, 10)
3737
topicARN, _ := queuectrl.Register("s3bucket")
3838
queueManager.Add(topicARN, queuemanager.HandlerFunc(QueueUpdater))
@@ -57,7 +57,7 @@ func (c *Operator) StartWatch(ctx context.Context, namespace string) {
5757
}
5858

5959
// QueueUpdater will take the messages from the queue and process them
60-
func QueueUpdater(config *config.Config, msg *queuemanager.MessageBody) error {
60+
func QueueUpdater(config config.Config, msg *queuemanager.MessageBody) error {
6161
logger := config.Logger
6262
var name, namespace string
6363
if msg.Updatable {
@@ -167,7 +167,7 @@ func (c *Operator) onDelete(obj interface{}) {
167167

168168
c.config.Logger.Infof("deleted s3bucket '%s'", s.Name)
169169
}
170-
func incrementRollbackCount(config *config.Config, name string, namespace string) error {
170+
func incrementRollbackCount(config config.Config, name string, namespace string) error {
171171
logger := config.Logger
172172
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
173173
resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{})
@@ -187,7 +187,7 @@ func incrementRollbackCount(config *config.Config, name string, namespace string
187187
return nil
188188
}
189189

190-
func updateStatus(config *config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.S3Bucket, error) {
190+
func updateStatus(config config.Config, name string, namespace string, stackID string, status string, reason string) (*awsV1alpha1.S3Bucket, error) {
191191
logger := config.Logger
192192
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
193193
resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{})
@@ -227,7 +227,7 @@ func updateStatus(config *config.Config, name string, namespace string, stackID
227227
return resourceCopy, nil
228228
}
229229

230-
func deleteStack(config *config.Config, name string, namespace string, stackID string) (*awsV1alpha1.S3Bucket, error) {
230+
func deleteStack(config config.Config, name string, namespace string, stackID string) (*awsV1alpha1.S3Bucket, error) {
231231
logger := config.Logger
232232
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
233233
resource, err := clientSet.S3Buckets(namespace).Get(name, metav1.GetOptions{})
@@ -246,7 +246,7 @@ func deleteStack(config *config.Config, name string, namespace string, stackID s
246246
return resource, err
247247
}
248248

249-
func syncAdditionalResources(config *config.Config, s *awsV1alpha1.S3Bucket) (err error) {
249+
func syncAdditionalResources(config config.Config, s *awsV1alpha1.S3Bucket) (err error) {
250250
clientSet, _ := awsclient.NewForConfig(config.RESTConfig)
251251
resource, err := clientSet.S3Buckets(s.Namespace).Get(s.Name, metav1.GetOptions{})
252252
if err != nil {

pkg/operators/snssubscription/cft.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// New generates a new object
18-
func New(config *config.Config, snssubscription *awsV1alpha1.SNSSubscription, topicARN string) *Cloudformation {
18+
func New(config config.Config, snssubscription *awsV1alpha1.SNSSubscription, topicARN string) *Cloudformation {
1919
return &Cloudformation{
2020
SNSSubscription: snssubscription,
2121
config: config,
@@ -25,7 +25,7 @@ func New(config *config.Config, snssubscription *awsV1alpha1.SNSSubscription, to
2525

2626
// Cloudformation defines the snssubscription cfts
2727
type Cloudformation struct {
28-
config *config.Config
28+
config config.Config
2929
SNSSubscription *awsV1alpha1.SNSSubscription
3030
topicARN string
3131
}

0 commit comments

Comments
 (0)