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 Removing Operator Kit
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 efc1608 commit daa0ac6
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 257 deletions.
82 changes: 44 additions & 38 deletions 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"
Expand All @@ -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
Expand Down
41 changes: 7 additions & 34 deletions pkg/operators/cloudformationtemplate/operator.go
Expand Up @@ -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,
}
}

Expand All @@ -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
}
Expand Down
42 changes: 9 additions & 33 deletions pkg/operators/dynamodb/operator.go
Expand Up @@ -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,
}
}

Expand All @@ -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
}
Expand Down
39 changes: 9 additions & 30 deletions pkg/operators/ecrrepository/operator.go
Expand Up @@ -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,
}
}

Expand All @@ -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
}
Expand Down

0 comments on commit daa0ac6

Please sign in to comment.