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

Commit daa0ac6

Browse files
Adding Generated Code for Removing Operator Kit
Signed-off-by: Christopher Hein <[email protected]>
1 parent efc1608 commit daa0ac6

File tree

8 files changed

+105
-257
lines changed

8 files changed

+105
-257
lines changed

pkg/operators/base/base.go

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package base
22

33
import (
4-
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
54
"github.com/awslabs/aws-service-operator/pkg/config"
65
"github.com/awslabs/aws-service-operator/pkg/operators/cloudformationtemplate"
76
"github.com/awslabs/aws-service-operator/pkg/operators/dynamodb"
@@ -10,62 +9,69 @@ import (
109
"github.com/awslabs/aws-service-operator/pkg/operators/snssubscription"
1110
"github.com/awslabs/aws-service-operator/pkg/operators/snstopic"
1211
"github.com/awslabs/aws-service-operator/pkg/operators/sqsqueue"
13-
opkit "github.com/christopherhein/operator-kit"
1412
)
1513

1614
type base struct {
17-
config *config.Config
18-
context *opkit.Context
19-
awsClientset awsclient.ServiceoperatorV1alpha1Interface
15+
config *config.Config
2016
}
2117

2218
func New(
2319
config *config.Config,
24-
context *opkit.Context,
25-
awsClientset awsclient.ServiceoperatorV1alpha1Interface,
2620
) *base {
2721
return &base{
28-
config: config,
29-
context: context,
30-
awsClientset: awsClientset,
22+
config: config,
3123
}
3224
}
3325

3426
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
27+
if b.config.Resources["cloudformationtemplate"] {
28+
cloudformationtemplateoperator := cloudformationtemplate.NewOperator(b.config)
29+
err = cloudformationtemplateoperator.StartWatch(namespace, stopCh)
30+
if err != nil {
31+
return err
32+
}
3933
}
40-
dynamodboperator := dynamodb.NewOperator(b.config, b.context, b.awsClientset)
41-
err = dynamodboperator.StartWatch(namespace, stopCh)
42-
if err != nil {
43-
return err
34+
if b.config.Resources["dynamodb"] {
35+
dynamodboperator := dynamodb.NewOperator(b.config)
36+
err = dynamodboperator.StartWatch(namespace, stopCh)
37+
if err != nil {
38+
return err
39+
}
4440
}
45-
ecrrepositoryoperator := ecrrepository.NewOperator(b.config, b.context, b.awsClientset)
46-
err = ecrrepositoryoperator.StartWatch(namespace, stopCh)
47-
if err != nil {
48-
return err
41+
if b.config.Resources["ecrrepository"] {
42+
ecrrepositoryoperator := ecrrepository.NewOperator(b.config)
43+
err = ecrrepositoryoperator.StartWatch(namespace, stopCh)
44+
if err != nil {
45+
return err
46+
}
4947
}
50-
s3bucketoperator := s3bucket.NewOperator(b.config, b.context, b.awsClientset)
51-
err = s3bucketoperator.StartWatch(namespace, stopCh)
52-
if err != nil {
53-
return err
48+
if b.config.Resources["s3bucket"] {
49+
s3bucketoperator := s3bucket.NewOperator(b.config)
50+
err = s3bucketoperator.StartWatch(namespace, stopCh)
51+
if err != nil {
52+
return err
53+
}
5454
}
55-
snssubscriptionoperator := snssubscription.NewOperator(b.config, b.context, b.awsClientset)
56-
err = snssubscriptionoperator.StartWatch(namespace, stopCh)
57-
if err != nil {
58-
return err
55+
if b.config.Resources["snssubscription"] {
56+
snssubscriptionoperator := snssubscription.NewOperator(b.config)
57+
err = snssubscriptionoperator.StartWatch(namespace, stopCh)
58+
if err != nil {
59+
return err
60+
}
5961
}
60-
snstopicoperator := snstopic.NewOperator(b.config, b.context, b.awsClientset)
61-
err = snstopicoperator.StartWatch(namespace, stopCh)
62-
if err != nil {
63-
return err
62+
if b.config.Resources["snstopic"] {
63+
snstopicoperator := snstopic.NewOperator(b.config)
64+
err = snstopicoperator.StartWatch(namespace, stopCh)
65+
if err != nil {
66+
return err
67+
}
6468
}
65-
sqsqueueoperator := sqsqueue.NewOperator(b.config, b.context, b.awsClientset)
66-
err = sqsqueueoperator.StartWatch(namespace, stopCh)
67-
if err != nil {
68-
return err
69+
if b.config.Resources["sqsqueue"] {
70+
sqsqueueoperator := sqsqueue.NewOperator(b.config)
71+
err = sqsqueueoperator.StartWatch(namespace, stopCh)
72+
if err != nil {
73+
return err
74+
}
6975
}
7076

7177
return nil

pkg/operators/cloudformationtemplate/operator.go

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,24 @@
66
package cloudformationtemplate
77

88
import (
9-
"reflect"
10-
119
"github.com/awslabs/aws-service-operator/pkg/config"
12-
opkit "github.com/christopherhein/operator-kit"
13-
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
10+
"github.com/awslabs/aws-service-operator/pkg/operator"
1411
"k8s.io/client-go/tools/cache"
1512

16-
awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws"
1713
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
18-
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
1914
"github.com/awslabs/aws-service-operator/pkg/customizations/cloudformationtemplate"
2015
)
2116

22-
// Resource is the object store definition
23-
var Resource = opkit.CustomResource{
24-
Name: "cloudformationtemplate",
25-
Plural: "cloudformationtemplates",
26-
Group: awsapi.GroupName,
27-
Version: awsapi.Version,
28-
Scope: apiextensionsv1beta1.NamespaceScoped,
29-
Kind: reflect.TypeOf(awsV1alpha1.CloudFormationTemplate{}).Name(),
30-
ShortNames: []string{
31-
"cft",
32-
"cfts",
33-
"cfn",
34-
"cfns",
35-
"cloudformation",
36-
},
37-
}
38-
3917
// Operator represents a controller object for object store custom resources
4018
type Operator struct {
41-
config *config.Config
42-
context *opkit.Context
43-
awsclientset awsclient.ServiceoperatorV1alpha1Interface
44-
topicARN string
19+
config *config.Config
20+
topicARN string
4521
}
4622

4723
// NewOperator create controller for watching object store custom resources created
48-
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
24+
func NewOperator(config *config.Config) *Operator {
4925
return &Operator{
50-
config: config,
51-
context: context,
52-
awsclientset: awsclientset,
26+
config: config,
5327
}
5428
}
5529

@@ -61,9 +35,8 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6135
DeleteFunc: c.onDelete,
6236
}
6337

64-
restClient := c.awsclientset.RESTClient()
65-
watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient)
66-
go watcher.Watch(&awsV1alpha1.CloudFormationTemplate{}, stopCh)
38+
oper := operator.New("cloudformationtemplates", namespace, resourceHandlers, c.config.AWSClientset.RESTClient())
39+
go oper.Watch(&awsV1alpha1.CloudFormationTemplate{}, stopCh)
6740

6841
return nil
6942
}

pkg/operators/dynamodb/operator.go

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,28 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
"reflect"
1212

13+
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
1314
"github.com/awslabs/aws-service-operator/pkg/config"
15+
"github.com/awslabs/aws-service-operator/pkg/operator"
1416
"github.com/awslabs/aws-service-operator/pkg/queue"
15-
opkit "github.com/christopherhein/operator-kit"
1617
"github.com/iancoleman/strcase"
1718
corev1 "k8s.io/api/core/v1"
18-
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
1919
"k8s.io/client-go/tools/cache"
2020
"strings"
2121

22-
awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws"
2322
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
24-
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
2523
)
2624

27-
// Resource is the object store definition
28-
var Resource = opkit.CustomResource{
29-
Name: "dynamodb",
30-
Plural: "dynamodbs",
31-
Group: awsapi.GroupName,
32-
Version: awsapi.Version,
33-
Scope: apiextensionsv1beta1.NamespaceScoped,
34-
Kind: reflect.TypeOf(awsV1alpha1.DynamoDB{}).Name(),
35-
ShortNames: []string{
36-
"ddb",
37-
"ddbs",
38-
"dynamo",
39-
"dynamotable",
40-
"dynamotables",
41-
},
42-
}
43-
4425
// Operator represents a controller object for object store custom resources
4526
type Operator struct {
46-
config *config.Config
47-
context *opkit.Context
48-
awsclientset awsclient.ServiceoperatorV1alpha1Interface
49-
topicARN string
27+
config *config.Config
28+
topicARN string
5029
}
5130

5231
// NewOperator create controller for watching object store custom resources created
53-
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
32+
func NewOperator(config *config.Config) *Operator {
5433
return &Operator{
55-
config: config,
56-
context: context,
57-
awsclientset: awsclientset,
34+
config: config,
5835
}
5936
}
6037

@@ -65,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6542
UpdateFunc: c.onUpdate,
6643
DeleteFunc: c.onDelete,
6744
}
68-
queuectrl := queue.New(c.config, c.context, c.awsclientset, 1)
45+
queuectrl := queue.New(c.config, c.config.AWSClientset, 1)
6946
c.topicARN, _, _, _ = queuectrl.Register("dynamodb", &awsV1alpha1.DynamoDB{})
7047
go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh)
7148

72-
restClient := c.awsclientset.RESTClient()
73-
watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient)
74-
go watcher.Watch(&awsV1alpha1.DynamoDB{}, stopCh)
49+
oper := operator.New("dynamodbs", namespace, resourceHandlers, c.config.AWSClientset.RESTClient())
50+
go oper.Watch(&awsV1alpha1.DynamoDB{}, stopCh)
7551

7652
return nil
7753
}

pkg/operators/ecrrepository/operator.go

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,28 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
"reflect"
1212

13+
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
1314
"github.com/awslabs/aws-service-operator/pkg/config"
15+
"github.com/awslabs/aws-service-operator/pkg/operator"
1416
"github.com/awslabs/aws-service-operator/pkg/queue"
15-
opkit "github.com/christopherhein/operator-kit"
1617
"github.com/iancoleman/strcase"
1718
corev1 "k8s.io/api/core/v1"
18-
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
1919
"k8s.io/client-go/tools/cache"
2020
"strings"
2121

22-
awsapi "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws"
2322
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
24-
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
2523
)
2624

27-
// Resource is the object store definition
28-
var Resource = opkit.CustomResource{
29-
Name: "ecrrepository",
30-
Plural: "ecrrepositories",
31-
Group: awsapi.GroupName,
32-
Version: awsapi.Version,
33-
Scope: apiextensionsv1beta1.NamespaceScoped,
34-
Kind: reflect.TypeOf(awsV1alpha1.ECRRepository{}).Name(),
35-
ShortNames: []string{
36-
"ecr",
37-
"repository",
38-
},
39-
}
40-
4125
// Operator represents a controller object for object store custom resources
4226
type Operator struct {
43-
config *config.Config
44-
context *opkit.Context
45-
awsclientset awsclient.ServiceoperatorV1alpha1Interface
46-
topicARN string
27+
config *config.Config
28+
topicARN string
4729
}
4830

4931
// NewOperator create controller for watching object store custom resources created
50-
func NewOperator(config *config.Config, context *opkit.Context, awsclientset awsclient.ServiceoperatorV1alpha1Interface) *Operator {
32+
func NewOperator(config *config.Config) *Operator {
5133
return &Operator{
52-
config: config,
53-
context: context,
54-
awsclientset: awsclientset,
34+
config: config,
5535
}
5636
}
5737

@@ -62,13 +42,12 @@ func (c *Operator) StartWatch(namespace string, stopCh chan struct{}) error {
6242
UpdateFunc: c.onUpdate,
6343
DeleteFunc: c.onDelete,
6444
}
65-
queuectrl := queue.New(c.config, c.context, c.awsclientset, 1)
45+
queuectrl := queue.New(c.config, c.config.AWSClientset, 1)
6646
c.topicARN, _, _, _ = queuectrl.Register("ecrrepository", &awsV1alpha1.ECRRepository{})
6747
go queuectrl.StartWatch(queue.HandlerFunc(QueueUpdater), stopCh)
6848

69-
restClient := c.awsclientset.RESTClient()
70-
watcher := opkit.NewWatcher(Resource, namespace, resourceHandlers, restClient)
71-
go watcher.Watch(&awsV1alpha1.ECRRepository{}, stopCh)
49+
oper := operator.New("ecrrepositories", namespace, resourceHandlers, c.config.AWSClientset.RESTClient())
50+
go oper.Watch(&awsV1alpha1.ECRRepository{}, stopCh)
7251

7352
return nil
7453
}

0 commit comments

Comments
 (0)