@@ -30,9 +30,9 @@ import (
30
30
"github.com/openshift/cluster-image-registry-operator/pkg/storage/s3"
31
31
)
32
32
33
- // AWSController is for storing internal data required for
33
+ // AWSTagController is for storing internal data required for
34
34
// performing AWS controller operations
35
- type AWSController struct {
35
+ type AWSTagController struct {
36
36
infraConfigClient configv1client.InfrastructureInterface
37
37
imageRegistryConfigClient imageregistryv1client.ConfigInterface
38
38
listers * regopclient.Listers
@@ -55,9 +55,9 @@ var kubernetesNamespaceRegex = regexp.MustCompile(`^([^/]*\.)?kubernetes.io/`)
55
55
// openshiftNamespaceRegex is used to check that a tag key is not in the openshift.io namespace.
56
56
var openshiftNamespaceRegex = regexp .MustCompile (`^([^/]*\.)?openshift.io/` )
57
57
58
- // NewAWSController is for obtaining AWSController object
59
- // required for invoking AWS controller methods.
60
- func NewAWSController (
58
+ // NewAWSTagController is for obtaining AWSTagController object
59
+ // required for invoking AWS Tag controller methods.
60
+ func NewAWSTagController (
61
61
infraConfigClient configv1client.InfrastructureInterface ,
62
62
imageRegistryConfigClient imageregistryv1client.ConfigInterface ,
63
63
kubeInformerFactory kubeinformers.SharedInformerFactory ,
@@ -68,15 +68,15 @@ func NewAWSController(
68
68
openshiftConfigManagedKubeInformerFactory kubeinformers.SharedInformerFactory ,
69
69
eventRecorder events.Recorder ,
70
70
featureGateAccessor featuregates.FeatureGateAccess ,
71
- ) (* AWSController , error ) {
72
- c := & AWSController {
71
+ ) (* AWSTagController , error ) {
72
+ c := & AWSTagController {
73
73
infraConfigClient : infraConfigClient ,
74
74
imageRegistryConfigClient : imageRegistryConfigClient ,
75
75
featureGateAccessor : featureGateAccessor ,
76
76
event : eventRecorder ,
77
77
queue : workqueue .NewNamedRateLimitingQueue (
78
78
workqueue .DefaultControllerRateLimiter (),
79
- "AWSController " ),
79
+ "AWSTagController " ),
80
80
}
81
81
82
82
infraConfig := configInformerFactory .Config ().V1 ().Infrastructures ()
@@ -118,15 +118,16 @@ func NewAWSController(
118
118
}
119
119
120
120
// eventHandler is the callback method for handling events from informer
121
- func (c * AWSController ) eventHandler () cache.ResourceEventHandler {
121
+ func (c * AWSTagController ) eventHandler () cache.ResourceEventHandler {
122
122
const workQueueKey = "aws"
123
123
return cache.ResourceEventHandlerFuncs {
124
124
AddFunc : func (obj interface {}) {
125
125
infra , ok := obj .(* configv1.Infrastructure )
126
126
if ! ok || infra == nil {
127
127
return
128
128
}
129
- if infra .Status .PlatformStatus .AWS != nil && len (infra .Status .PlatformStatus .AWS .ResourceTags ) != 0 {
129
+ if infra .Status .PlatformStatus != nil && infra .Status .PlatformStatus .AWS != nil &&
130
+ len (infra .Status .PlatformStatus .AWS .ResourceTags ) != 0 {
130
131
c .queue .Add (workQueueKey )
131
132
return
132
133
}
@@ -140,7 +141,8 @@ func (c *AWSController) eventHandler() cache.ResourceEventHandler {
140
141
if ! ok || newInfra == nil {
141
142
return
142
143
}
143
- if oldInfra .Status .PlatformStatus .AWS != nil && newInfra .Status .PlatformStatus .AWS != nil {
144
+ if oldInfra .Status .PlatformStatus != nil && oldInfra .Status .PlatformStatus .AWS != nil &&
145
+ newInfra .Status .PlatformStatus != nil && newInfra .Status .PlatformStatus .AWS != nil {
144
146
if ! reflect .DeepEqual (oldInfra .Status .PlatformStatus .AWS .ResourceTags , newInfra .Status .PlatformStatus .AWS .ResourceTags ) {
145
147
c .queue .Add (workQueueKey )
146
148
return
@@ -151,7 +153,7 @@ func (c *AWSController) eventHandler() cache.ResourceEventHandler {
151
153
}
152
154
153
155
// Run is the main method for starting the AWS controller
154
- func (c * AWSController ) Run (ctx context.Context ) {
156
+ func (c * AWSTagController ) Run (ctx context.Context ) {
155
157
defer k8sruntime .HandleCrash ()
156
158
defer c .queue .ShutDown ()
157
159
@@ -167,14 +169,14 @@ func (c *AWSController) Run(ctx context.Context) {
167
169
klog .Infof ("Shutting down AWS Controller" )
168
170
}
169
171
170
- func (c * AWSController ) runWorker () {
172
+ func (c * AWSTagController ) runWorker () {
171
173
for c .processNextWorkItem () {
172
174
}
173
175
}
174
176
175
177
// processNextWorkItem is for prcessing the event received
176
178
// which blocks until a new item is received
177
- func (c * AWSController ) processNextWorkItem () bool {
179
+ func (c * AWSTagController ) processNextWorkItem () bool {
178
180
obj , shutdown := c .queue .Get ()
179
181
if shutdown {
180
182
return false
@@ -196,14 +198,14 @@ func (c *AWSController) processNextWorkItem() bool {
196
198
// on receiving a informer event.
197
199
// Fetches image registry config data, required for obtaining
198
200
// the S3 bucket configuration and creating a driver out of it
199
- func (c * AWSController ) sync () error {
201
+ func (c * AWSTagController ) sync () error {
200
202
return c .syncTags ()
201
203
}
202
204
203
205
// syncTags fetches user tags from Infrastructure resource, which
204
206
// is then compared with the tags configured for the created S3 bucket
205
207
// fetched using the driver object passed and updates if any new tags.
206
- func (c * AWSController ) syncTags () error {
208
+ func (c * AWSTagController ) syncTags () error {
207
209
cr , err := c .imageRegistryConfigClient .Get (
208
210
context .Background (),
209
211
defaults .ImageRegistryResourceName ,
0 commit comments