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

Commit

Permalink
Adding Generated code for loading list of services
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Oct 16, 2018
1 parent 7008af8 commit 4c6e4c5
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 63 deletions.
5 changes: 5 additions & 0 deletions configs/aws-service-operator.yaml
@@ -1,3 +1,8 @@
# >>>>>>> DO NOT EDIT THIS FILE <<<<<<<<<<
# This file is autogenerated via `aws-operator generate`
# If you'd like the change anything about this file make edits to the .templ
# file in the pkg/codegen/assets directory.

apiVersion: v1
kind: List
items:
Expand Down
Empty file removed pkg/operator/.gitkeep
Empty file.
72 changes: 72 additions & 0 deletions pkg/operators/base/base.go
@@ -0,0 +1,72 @@
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"
"github.com/awslabs/aws-service-operator/pkg/operators/ecrrepository"
"github.com/awslabs/aws-service-operator/pkg/operators/s3bucket"
"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
}

func New(
config *config.Config,
context *opkit.Context,
awsClientset awsclient.ServiceoperatorV1alpha1Interface,
) *base {
return &base{
config: config,
context: context,
awsClientset: awsClientset,
}
}

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
}
dynamodboperator := dynamodb.NewOperator(b.config, b.context, b.awsClientset)
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
}
s3bucketoperator := s3bucket.NewOperator(b.config, b.context, b.awsClientset)
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
}
snstopicoperator := snstopic.NewOperator(b.config, b.context, b.awsClientset)
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
}

return nil
}
Expand Up @@ -36,25 +36,25 @@ var Resource = opkit.CustomResource{
},
}

// Controller represents a controller object for object store custom resources
type Controller struct {
// Operator represents a controller object for object store custom resources
type Operator struct {
config *config.Config
context *opkit.Context
awsclientset awsclient.ServiceoperatorV1alpha1Interface
topicARN string
}

// NewController create controller for watching object store custom resources created
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
return &Controller{
// NewOperator create controller for watching object store custom resources created
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
return &Operator{
config: config,
context: context,
awsclientset: awsclientset,
}
}

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

func (c *Controller) onAdd(obj interface{}) {
func (c *Operator) onAdd(obj interface{}) {
s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
cloudformationtemplate.OnAdd(c.config, s)
}

func (c *Controller) onUpdate(oldObj, newObj interface{}) {
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
oo := oldObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
no := newObj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()

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

func (c *Controller) onDelete(obj interface{}) {
func (c *Operator) onDelete(obj interface{}) {
s := obj.(*awsV1alpha1.CloudFormationTemplate).DeepCopy()
cloudformationtemplate.OnDelete(c.config, s)
}
File renamed without changes.
Expand Up @@ -41,25 +41,25 @@ var Resource = opkit.CustomResource{
},
}

// Controller represents a controller object for object store custom resources
type Controller struct {
// Operator represents a controller object for object store custom resources
type Operator struct {
config *config.Config
context *opkit.Context
awsclientset awsclient.ServiceoperatorV1alpha1Interface
topicARN string
}

// NewController create controller for watching object store custom resources created
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
return &Controller{
// NewOperator create controller for watching object store custom resources created
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
return &Operator{
config: config,
context: context,
awsclientset: awsclientset,
}
}

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

func (c *Controller) onAdd(obj interface{}) {
func (c *Operator) onAdd(obj interface{}) {
s := obj.(*awsV1alpha1.DynamoDB).DeepCopy()
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
cft := New(c.config, s, c.topicARN)
Expand All @@ -152,7 +152,7 @@ func (c *Controller) onAdd(obj interface{}) {
}
}

func (c *Controller) onUpdate(oldObj, newObj interface{}) {
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
oo := oldObj.(*awsV1alpha1.DynamoDB).DeepCopy()
no := newObj.(*awsV1alpha1.DynamoDB).DeepCopy()

Expand All @@ -176,7 +176,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
}
}

func (c *Controller) onDelete(obj interface{}) {
func (c *Operator) onDelete(obj interface{}) {
s := obj.(*awsV1alpha1.DynamoDB).DeepCopy()
cft := New(c.config, s, c.topicARN)
err := cft.DeleteStack()
Expand Down
File renamed without changes.
Expand Up @@ -38,25 +38,25 @@ var Resource = opkit.CustomResource{
},
}

// Controller represents a controller object for object store custom resources
type Controller struct {
// Operator represents a controller object for object store custom resources
type Operator struct {
config *config.Config
context *opkit.Context
awsclientset awsclient.ServiceoperatorV1alpha1Interface
topicARN string
}

// NewController create controller for watching object store custom resources created
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
return &Controller{
// NewOperator create controller for watching object store custom resources created
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
return &Operator{
config: config,
context: context,
awsclientset: awsclientset,
}
}

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

func (c *Controller) onAdd(obj interface{}) {
func (c *Operator) onAdd(obj interface{}) {
s := obj.(*awsV1alpha1.ECRRepository).DeepCopy()
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
cft := New(c.config, s, c.topicARN)
Expand All @@ -149,7 +149,7 @@ func (c *Controller) onAdd(obj interface{}) {
}
}

func (c *Controller) onUpdate(oldObj, newObj interface{}) {
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
oo := oldObj.(*awsV1alpha1.ECRRepository).DeepCopy()
no := newObj.(*awsV1alpha1.ECRRepository).DeepCopy()

Expand All @@ -173,7 +173,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
}
}

func (c *Controller) onDelete(obj interface{}) {
func (c *Operator) onDelete(obj interface{}) {
s := obj.(*awsV1alpha1.ECRRepository).DeepCopy()
cft := New(c.config, s, c.topicARN)
err := cft.DeleteStack()
Expand Down
File renamed without changes.
Expand Up @@ -39,25 +39,25 @@ var Resource = opkit.CustomResource{
},
}

// Controller represents a controller object for object store custom resources
type Controller struct {
// Operator represents a controller object for object store custom resources
type Operator struct {
config *config.Config
context *opkit.Context
awsclientset awsclient.ServiceoperatorV1alpha1Interface
topicARN string
}

// NewController create controller for watching object store custom resources created
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
return &Controller{
// NewOperator create controller for watching object store custom resources created
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
return &Operator{
config: config,
context: context,
awsclientset: awsclientset,
}
}

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

func (c *Controller) onAdd(obj interface{}) {
func (c *Operator) onAdd(obj interface{}) {
s := obj.(*awsV1alpha1.S3Bucket).DeepCopy()
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
cft := New(c.config, s, c.topicARN)
Expand All @@ -150,7 +150,7 @@ func (c *Controller) onAdd(obj interface{}) {
}
}

func (c *Controller) onUpdate(oldObj, newObj interface{}) {
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
oo := oldObj.(*awsV1alpha1.S3Bucket).DeepCopy()
no := newObj.(*awsV1alpha1.S3Bucket).DeepCopy()

Expand All @@ -174,7 +174,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
}
}

func (c *Controller) onDelete(obj interface{}) {
func (c *Operator) onDelete(obj interface{}) {
s := obj.(*awsV1alpha1.S3Bucket).DeepCopy()
cft := New(c.config, s, c.topicARN)
err := cft.DeleteStack()
Expand Down
File renamed without changes.
Expand Up @@ -37,25 +37,25 @@ var Resource = opkit.CustomResource{
},
}

// Controller represents a controller object for object store custom resources
type Controller struct {
// Operator represents a controller object for object store custom resources
type Operator struct {
config *config.Config
context *opkit.Context
awsclientset awsclient.ServiceoperatorV1alpha1Interface
topicARN string
}

// NewController create controller for watching object store custom resources created
func NewController(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Controller {
return &Controller{
// NewOperator create controller for watching object store custom resources created
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
return &Operator{
config: config,
context: context,
awsclientset: awsclientset,
}
}

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

func (c *Controller) onAdd(obj interface{}) {
func (c *Operator) onAdd(obj interface{}) {
s := obj.(*awsV1alpha1.SNSSubscription).DeepCopy()
if s.Status.ResourceStatus == "" || s.Status.ResourceStatus == "DELETE_COMPLETE" {
cft := New(c.config, s, c.topicARN)
Expand All @@ -148,7 +148,7 @@ func (c *Controller) onAdd(obj interface{}) {
}
}

func (c *Controller) onUpdate(oldObj, newObj interface{}) {
func (c *Operator) onUpdate(oldObj, newObj interface{}) {
oo := oldObj.(*awsV1alpha1.SNSSubscription).DeepCopy()
no := newObj.(*awsV1alpha1.SNSSubscription).DeepCopy()

Expand All @@ -172,7 +172,7 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
}
}

func (c *Controller) onDelete(obj interface{}) {
func (c *Operator) onDelete(obj interface{}) {
s := obj.(*awsV1alpha1.SNSSubscription).DeepCopy()
cft := New(c.config, s, c.topicARN)
err := cft.DeleteStack()
Expand Down
File renamed without changes.

0 comments on commit 4c6e4c5

Please sign in to comment.