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

Commit 4c6e4c5

Browse files
Adding Generated code for loading list of services
Signed-off-by: Christopher Hein <[email protected]>
1 parent 7008af8 commit 4c6e4c5

File tree

16 files changed

+140
-63
lines changed

16 files changed

+140
-63
lines changed

configs/aws-service-operator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# >>>>>>> DO NOT EDIT THIS FILE <<<<<<<<<<
2+
# This file is autogenerated via `aws-operator generate`
3+
# If you'd like the change anything about this file make edits to the .templ
4+
# file in the pkg/codegen/assets directory.
5+
16
apiVersion: v1
27
kind: List
38
items:

pkg/operator/.gitkeep

Whitespace-only changes.

pkg/operators/base/base.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package base
2+
3+
import (
4+
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
5+
"github.com/awslabs/aws-service-operator/pkg/config"
6+
"github.com/awslabs/aws-service-operator/pkg/operators/cloudformationtemplate"
7+
"github.com/awslabs/aws-service-operator/pkg/operators/dynamodb"
8+
"github.com/awslabs/aws-service-operator/pkg/operators/ecrrepository"
9+
"github.com/awslabs/aws-service-operator/pkg/operators/s3bucket"
10+
"github.com/awslabs/aws-service-operator/pkg/operators/snssubscription"
11+
"github.com/awslabs/aws-service-operator/pkg/operators/snstopic"
12+
"github.com/awslabs/aws-service-operator/pkg/operators/sqsqueue"
13+
opkit "github.com/christopherhein/operator-kit"
14+
)
15+
16+
type base struct {
17+
config *config.Config
18+
context *opkit.Context
19+
awsClientset awsclient.ServiceoperatorV1alpha1Interface
20+
}
21+
22+
func New(
23+
config *config.Config,
24+
context *opkit.Context,
25+
awsClientset awsclient.ServiceoperatorV1alpha1Interface,
26+
) *base {
27+
return &base{
28+
config: config,
29+
context: context,
30+
awsClientset: awsClientset,
31+
}
32+
}
33+
34+
func (b *base) Watch(namespace string, stopCh chan struct{}) (err error) {
35+
cloudformationtemplateoperator := cloudformationtemplate.NewOperator(b.config, b.context, b.awsClientset)
36+
err = cloudformationtemplateoperator.StartWatch(namespace, stopCh)
37+
if err != nil {
38+
return err
39+
}
40+
dynamodboperator := dynamodb.NewOperator(b.config, b.context, b.awsClientset)
41+
err = dynamodboperator.StartWatch(namespace, stopCh)
42+
if err != nil {
43+
return err
44+
}
45+
ecrrepositoryoperator := ecrrepository.NewOperator(b.config, b.context, b.awsClientset)
46+
err = ecrrepositoryoperator.StartWatch(namespace, stopCh)
47+
if err != nil {
48+
return err
49+
}
50+
s3bucketoperator := s3bucket.NewOperator(b.config, b.context, b.awsClientset)
51+
err = s3bucketoperator.StartWatch(namespace, stopCh)
52+
if err != nil {
53+
return err
54+
}
55+
snssubscriptionoperator := snssubscription.NewOperator(b.config, b.context, b.awsClientset)
56+
err = snssubscriptionoperator.StartWatch(namespace, stopCh)
57+
if err != nil {
58+
return err
59+
}
60+
snstopicoperator := snstopic.NewOperator(b.config, b.context, b.awsClientset)
61+
err = snstopicoperator.StartWatch(namespace, stopCh)
62+
if err != nil {
63+
return err
64+
}
65+
sqsqueueoperator := sqsqueue.NewOperator(b.config, b.context, b.awsClientset)
66+
err = sqsqueueoperator.StartWatch(namespace, stopCh)
67+
if err != nil {
68+
return err
69+
}
70+
71+
return nil
72+
}

pkg/operator/cloudformationtemplate/operator.go renamed to pkg/operators/cloudformationtemplate/operator.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ var Resource = opkit.CustomResource{
3636
},
3737
}
3838

39-
// Controller represents a controller object for object store custom resources
40-
type Controller struct {
39+
// Operator represents a controller object for object store custom resources
40+
type Operator struct {
4141
config *config.Config
4242
context *opkit.Context
4343
awsclientset awsclient.ServiceoperatorV1alpha1Interface
4444
topicARN string
4545
}
4646

47-
// NewController create controller for watching object store custom resources created
48-
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
49-
return &Controller{
47+
// NewOperator create controller for watching object store custom resources created
48+
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
49+
return &Operator{
5050
config: config,
5151
context: context,
5252
awsclientset: awsclientset,
5353
}
5454
}
5555

5656
// StartWatch watches for instances of Object Store custom resources and acts on them
57-
func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error {
57+
func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
5858
resourceHandlers := cache.ResourceEventHandlerFuncs{
5959
AddFunc: c.onAdd,
6060
UpdateFunc: c.onUpdate,
@@ -68,12 +68,12 @@ func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error {
6868
return nil
6969
}
7070

71-
func (c *Controller) onAdd(obj interface{}) {
71+
func (c *Operator) onAdd(obj interface{}) {
7272
s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
7373
cloudformationtemplate.OnAdd(c.config, s)
7474
}
7575

76-
func (c *Controller) onUpdate(oldObj, newObj interface{}) {
76+
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
7777
oo := oldObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
7878
no := newObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
7979

@@ -83,7 +83,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
8383
cloudformationtemplate.OnUpdate(c.config, oo, no)
8484
}
8585

86-
func (c *Controller) onDelete(obj interface{}) {
86+
func (c *Operator) onDelete(obj interface{}) {
8787
s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
8888
cloudformationtemplate.OnDelete(c.config, s)
8989
}
File renamed without changes.

pkg/operator/dynamodb/operator.go renamed to pkg/operators/dynamodb/operator.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ var Resource = opkit.CustomResource{
4141
},
4242
}
4343

44-
// Controller represents a controller object for object store custom resources
45-
type Controller struct {
44+
// Operator represents a controller object for object store custom resources
45+
type Operator struct {
4646
config *config.Config
4747
context *opkit.Context
4848
awsclientset awsclient.ServiceoperatorV1alpha1Interface
4949
topicARN string
5050
}
5151

52-
// NewController create controller for watching object store custom resources created
53-
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
54-
return &Controller{
52+
// NewOperator create controller for watching object store custom resources created
53+
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
54+
return &Operator{
5555
config: config,
5656
context: context,
5757
awsclientset: awsclientset,
5858
}
5959
}
6060

6161
// StartWatch watches for instances of Object Store custom resources and acts on them
62-
func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error {
62+
func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6363
resourceHandlers := cache.ResourceEventHandlerFuncs{
6464
AddFunc: c.onAdd,
6565
UpdateFunc: c.onUpdate,
@@ -133,7 +133,7 @@ func QueueUpdater(config *config.Config, msg *queue.MessageBody) error {
133133
return nil
134134
}
135135

136-
func (c *Controller) onAdd(obj interface{}) {
136+
func (c *Operator) onAdd(obj interface{}) {
137137
s := obj.(*awsV1alpha1.DynamoDB).DeepCopy()
138138
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
139139
cft := New(c.config, s, c.topicARN)
@@ -152,7 +152,7 @@ func (c *Controller) onAdd(obj interface{}) {
152152
}
153153
}
154154

155-
func (c *Controller) onUpdate(oldObj, newObj interface{}) {
155+
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
156156
oo := oldObj.(*awsV1alpha1.DynamoDB).DeepCopy()
157157
no := newObj.(*awsV1alpha1.DynamoDB).DeepCopy()
158158

@@ -176,7 +176,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
176176
}
177177
}
178178

179-
func (c *Controller) onDelete(obj interface{}) {
179+
func (c *Operator) onDelete(obj interface{}) {
180180
s := obj.(*awsV1alpha1.DynamoDB).DeepCopy()
181181
cft := New(c.config, s, c.topicARN)
182182
err := cft.DeleteStack()

pkg/operator/ecrrepository/operator.go renamed to pkg/operators/ecrrepository/operator.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ var Resource = opkit.CustomResource{
3838
},
3939
}
4040

41-
// Controller represents a controller object for object store custom resources
42-
type Controller struct {
41+
// Operator represents a controller object for object store custom resources
42+
type Operator struct {
4343
config *config.Config
4444
context *opkit.Context
4545
awsclientset awsclient.ServiceoperatorV1alpha1Interface
4646
topicARN string
4747
}
4848

49-
// NewController create controller for watching object store custom resources created
50-
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
51-
return &Controller{
49+
// NewOperator create controller for watching object store custom resources created
50+
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
51+
return &Operator{
5252
config: config,
5353
context: context,
5454
awsclientset: awsclientset,
5555
}
5656
}
5757

5858
// StartWatch watches for instances of Object Store custom resources and acts on them
59-
func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error {
59+
func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6060
resourceHandlers := cache.ResourceEventHandlerFuncs{
6161
AddFunc: c.onAdd,
6262
UpdateFunc: c.onUpdate,
@@ -130,7 +130,7 @@ func QueueUpdater(config *config.Config, msg *queue.MessageBody) error {
130130
return nil
131131
}
132132

133-
func (c *Controller) onAdd(obj interface{}) {
133+
func (c *Operator) onAdd(obj interface{}) {
134134
s := obj.(*awsV1alpha1.ECRRepository).DeepCopy()
135135
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
136136
cft := New(c.config, s, c.topicARN)
@@ -149,7 +149,7 @@ func (c *Controller) onAdd(obj interface{}) {
149149
}
150150
}
151151

152-
func (c *Controller) onUpdate(oldObj, newObj interface{}) {
152+
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
153153
oo := oldObj.(*awsV1alpha1.ECRRepository).DeepCopy()
154154
no := newObj.(*awsV1alpha1.ECRRepository).DeepCopy()
155155

@@ -173,7 +173,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
173173
}
174174
}
175175

176-
func (c *Controller) onDelete(obj interface{}) {
176+
func (c *Operator) onDelete(obj interface{}) {
177177
s := obj.(*awsV1alpha1.ECRRepository).DeepCopy()
178178
cft := New(c.config, s, c.topicARN)
179179
err := cft.DeleteStack()
File renamed without changes.

pkg/operator/s3bucket/operator.go renamed to pkg/operators/s3bucket/operator.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ var Resource = opkit.CustomResource{
3939
},
4040
}
4141

42-
// Controller represents a controller object for object store custom resources
43-
type Controller struct {
42+
// Operator represents a controller object for object store custom resources
43+
type Operator struct {
4444
config *config.Config
4545
context *opkit.Context
4646
awsclientset awsclient.ServiceoperatorV1alpha1Interface
4747
topicARN string
4848
}
4949

50-
// NewController create controller for watching object store custom resources created
51-
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
52-
return &Controller{
50+
// NewOperator create controller for watching object store custom resources created
51+
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
52+
return &Operator{
5353
config: config,
5454
context: context,
5555
awsclientset: awsclientset,
5656
}
5757
}
5858

5959
// StartWatch watches for instances of Object Store custom resources and acts on them
60-
func (c *Controller) StartWatch(namespace string, stopCh chan struct{}) error {
60+
func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6161
resourceHandlers := cache.ResourceEventHandlerFuncs{
6262
AddFunc: c.onAdd,
6363
UpdateFunc: c.onUpdate,
@@ -131,7 +131,7 @@ func QueueUpdater(config *config.Config, msg *queue.MessageBody) error {
131131
return nil
132132
}
133133

134-
func (c *Controller) onAdd(obj interface{}) {
134+
func (c *Operator) onAdd(obj interface{}) {
135135
s := obj.(*awsV1alpha1.S3Bucket).DeepCopy()
136136
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
137137
cft := New(c.config, s, c.topicARN)
@@ -150,7 +150,7 @@ func (c *Controller) onAdd(obj interface{}) {
150150
}
151151
}
152152

153-
func (c *Controller) onUpdate(oldObj, newObj interface{}) {
153+
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
154154
oo := oldObj.(*awsV1alpha1.S3Bucket).DeepCopy()
155155
no := newObj.(*awsV1alpha1.S3Bucket).DeepCopy()
156156

@@ -174,7 +174,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
174174
}
175175
}
176176

177-
func (c *Controller) onDelete(obj interface{}) {
177+
func (c *Operator) onDelete(obj interface{}) {
178178
s := obj.(*awsV1alpha1.S3Bucket).DeepCopy()
179179
cft := New(c.config, s, c.topicARN)
180180
err := cft.DeleteStack()

0 commit comments

Comments
 (0)