@@ -10,13 +10,7 @@ import (
10
10
awsscheme "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/scheme"
11
11
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
12
12
"github.com/awslabs/aws-service-operator/pkg/config"
13
- "github.com/awslabs/aws-service-operator/pkg/operator/cloudformationtemplate"
14
- "github.com/awslabs/aws-service-operator/pkg/operator/dynamodb"
15
- "github.com/awslabs/aws-service-operator/pkg/operator/ecrrepository"
16
- "github.com/awslabs/aws-service-operator/pkg/operator/s3bucket"
17
- "github.com/awslabs/aws-service-operator/pkg/operator/snssubscription"
18
- "github.com/awslabs/aws-service-operator/pkg/operator/snstopic"
19
- "github.com/awslabs/aws-service-operator/pkg/operator/sqsqueue"
13
+ opBase "github.com/awslabs/aws-service-operator/pkg/operators/base"
20
14
opkit "github.com/christopherhein/operator-kit"
21
15
corev1 "k8s.io/api/core/v1"
22
16
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
@@ -41,7 +35,7 @@ func New(config *config.Config) *Server {
41
35
func (c * Server ) Run (stopChan chan struct {}) {
42
36
config := c .Config
43
37
logger := config .Logger
44
- logger .Info ("Getting kubernetes context" )
38
+ logger .Info ("getting kubernetes context" )
45
39
context , restConfig , kubeclientset , awsClientset , err := createContext (config .Kubeconfig )
46
40
if err != nil {
47
41
logger .Fatalf ("failed to create context. %+v\n " , err )
@@ -64,13 +58,13 @@ func (c *Server) Run(stopChan chan struct{}) {
64
58
region = config .Region
65
59
}
66
60
67
- logger .Infof ("Region : %+v" , region )
61
+ logger .Infof ("region : %+v" , region )
68
62
69
63
sess , err := session .NewSession (& aws.Config {
70
64
Region : aws .String (region ),
71
65
})
72
66
if err != nil {
73
- logger .Infof ("Error creating AWS session '%s'\n " , err )
67
+ logger .Infof ("error creating AWS session '%s'\n " , err )
74
68
}
75
69
config .AWSSession = sess
76
70
@@ -83,37 +77,22 @@ func (c *Server) Run(stopChan chan struct{}) {
83
77
84
78
// start watching the aws operator resources
85
79
logger .Info ("Watching the resources" )
86
- cftcontroller := cloudformationtemplate .NewController (config , context , awsClientset )
87
- cftcontroller .StartWatch (corev1 .NamespaceAll , stopChan )
88
-
89
- s3controller := s3bucket .NewController (config , context , awsClientset )
90
- s3controller .StartWatch (corev1 .NamespaceAll , stopChan )
91
-
92
- ddbcontroller := dynamodb .NewController (config , context , awsClientset )
93
- ddbcontroller .StartWatch (corev1 .NamespaceAll , stopChan )
94
-
95
- sqscontroller := sqsqueue .NewController (config , context , awsClientset )
96
- sqscontroller .StartWatch (corev1 .NamespaceAll , stopChan )
97
-
98
- ecrcontroller := ecrrepository .NewController (config , context , awsClientset )
99
- ecrcontroller .StartWatch (corev1 .NamespaceAll , stopChan )
100
-
101
- snscontroller := snstopic .NewController (config , context , awsClientset )
102
- snscontroller .StartWatch (corev1 .NamespaceAll , stopChan )
103
-
104
- snssubcontroller := snssubscription .NewController (config , context , awsClientset )
105
- snssubcontroller .StartWatch (corev1 .NamespaceAll , stopChan )
80
+ operators := opBase .New (config , context , awsClientset )
81
+ err = operators .Watch (corev1 .NamespaceAll , stopChan )
82
+ if err != nil {
83
+ logger .Infof ("error watching operators '%s'\n " , err )
84
+ }
106
85
}
107
86
108
- func getClientConfig (kubeconfig string ) (* rest.Config , error ) {
87
+ func getConfig (kubeconfig string ) (* rest.Config , error ) {
109
88
if kubeconfig != "" {
110
89
return clientcmd .BuildConfigFromFlags ("" , kubeconfig )
111
90
}
112
91
return rest .InClusterConfig ()
113
92
}
114
93
115
94
func createContext (kubeconfig string ) (* opkit.Context , * rest.Config , kubernetes.Interface , awsclient.ServiceoperatorV1alpha1Interface , error ) {
116
- config , err := getClientConfig (kubeconfig )
95
+ config , err := getConfig (kubeconfig )
117
96
if err != nil {
118
97
return nil , nil , nil , nil , fmt .Errorf ("failed to get k8s config. %+v" , err )
119
98
}
0 commit comments