@@ -17,6 +17,8 @@ import (
17
17
"context"
18
18
"strings"
19
19
20
+ "github.com/pkg/errors"
21
+
20
22
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
21
23
ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
22
24
ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
@@ -50,6 +52,8 @@ const (
50
52
ConfigurationActionUpdate
51
53
)
52
54
55
+ const ErrSyncingPutProperty = "Error syncing property '%s'"
56
+
53
57
func (rm * resourceManager ) createPutFields (
54
58
ctx context.Context ,
55
59
r * resource ,
@@ -64,87 +68,87 @@ func (rm *resourceManager) createPutFields(
64
68
65
69
if r .ko .Spec .Accelerate != nil {
66
70
if err := rm .syncAccelerate (ctx , r ); err != nil {
67
- return err
71
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Accelerate" )
68
72
}
69
73
}
70
74
if len (r .ko .Spec .Analytics ) != 0 {
71
75
if err := rm .syncAnalytics (ctx , r , nil ); err != nil {
72
- return err
76
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Analytics" )
73
77
}
74
78
}
75
79
if r .ko .Spec .CORS != nil {
76
80
if err := rm .syncCORS (ctx , r ); err != nil {
77
- return err
81
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "CORS" )
78
82
}
79
83
}
80
84
if r .ko .Spec .Encryption != nil {
81
85
if err := rm .syncEncryption (ctx , r ); err != nil {
82
- return err
86
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Encryption" )
83
87
}
84
88
}
85
89
if len (r .ko .Spec .IntelligentTiering ) != 0 {
86
90
if err := rm .syncIntelligentTiering (ctx , r , nil ); err != nil {
87
- return err
91
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "IntelligentTiering" )
88
92
}
89
93
}
90
94
if len (r .ko .Spec .Inventory ) != 0 {
91
95
if err := rm .syncInventory (ctx , r , nil ); err != nil {
92
- return err
96
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Inventory" )
93
97
}
94
98
}
95
99
if r .ko .Spec .Lifecycle != nil {
96
100
if err := rm .syncLifecycle (ctx , r ); err != nil {
97
- return err
101
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Lifecycle" )
98
102
}
99
103
}
100
104
if r .ko .Spec .Logging != nil {
101
105
if err := rm .syncLogging (ctx , r ); err != nil {
102
- return err
106
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Logging" )
103
107
}
104
108
}
105
109
if len (r .ko .Spec .Metrics ) != 0 {
106
110
if err := rm .syncMetrics (ctx , r , nil ); err != nil {
107
- return err
111
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Metrics" )
108
112
}
109
113
}
110
114
if r .ko .Spec .Notification != nil {
111
115
if err := rm .syncNotification (ctx , r ); err != nil {
112
- return err
116
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Notification" )
113
117
}
114
118
}
115
119
if r .ko .Spec .OwnershipControls != nil {
116
120
if err := rm .syncOwnershipControls (ctx , r ); err != nil {
117
- return err
121
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "OwnershipControls" )
118
122
}
119
123
}
120
124
if r .ko .Spec .Policy != nil {
121
125
if err := rm .syncPolicy (ctx , r ); err != nil {
122
- return err
126
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Policy" )
123
127
}
124
128
}
125
129
if r .ko .Spec .PublicAccessBlock != nil {
126
130
if err := rm .syncPublicAccessBlock (ctx , r ); err != nil {
127
- return err
131
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "PublicAccessBlock" )
128
132
}
129
133
}
130
134
if r .ko .Spec .Replication != nil {
131
135
if err := rm .syncReplication (ctx , r ); err != nil {
132
- return err
136
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
133
137
}
134
138
}
135
139
if r .ko .Spec .RequestPayment != nil {
136
140
if err := rm .syncRequestPayment (ctx , r ); err != nil {
137
- return err
141
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "RequestPayment" )
138
142
}
139
143
}
140
144
if r .ko .Spec .Tagging != nil {
141
145
if err := rm .syncTagging (ctx , r ); err != nil {
142
- return err
146
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Tagging" )
143
147
}
144
148
}
145
149
if r .ko .Spec .Website != nil {
146
150
if err := rm .syncWebsite (ctx , r ); err != nil {
147
- return err
151
+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Website" )
148
152
}
149
153
}
150
154
return nil
@@ -170,12 +174,12 @@ func (rm *resourceManager) customUpdateBucket(
170
174
171
175
if delta .DifferentAt ("Spec.Accelerate" ) {
172
176
if err := rm .syncAccelerate (ctx , desired ); err != nil {
173
- return nil , err
177
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Accelerate" )
174
178
}
175
179
}
176
180
if delta .DifferentAt ("Spec.Analytics" ) {
177
181
if err := rm .syncAnalytics (ctx , desired , latest ); err != nil {
178
- return nil , err
182
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Analytics" )
179
183
}
180
184
}
181
185
if delta .DifferentAt ("Spec.ACL" ) ||
@@ -185,77 +189,77 @@ func (rm *resourceManager) customUpdateBucket(
185
189
delta .DifferentAt ("Spec.GrantWrite" ) ||
186
190
delta .DifferentAt ("Spec.GrantWriteACP" ) {
187
191
if err := rm .syncACL (ctx , desired ); err != nil {
188
- return nil , err
192
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "ACLs or Grant Headers" )
189
193
}
190
194
}
191
195
if delta .DifferentAt ("Spec.CORS" ) {
192
196
if err := rm .syncCORS (ctx , desired ); err != nil {
193
- return nil , err
197
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "CORS" )
194
198
}
195
199
}
196
200
if delta .DifferentAt ("Spec.Encryption" ) {
197
201
if err := rm .syncEncryption (ctx , desired ); err != nil {
198
- return nil , err
202
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Encryption" )
199
203
}
200
204
}
201
205
if delta .DifferentAt ("Spec.IntelligentTiering" ) {
202
206
if err := rm .syncIntelligentTiering (ctx , desired , latest ); err != nil {
203
- return nil , err
207
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "IntelligentTiering" )
204
208
}
205
209
}
206
210
if delta .DifferentAt ("Spec.Inventory" ) {
207
211
if err := rm .syncInventory (ctx , desired , latest ); err != nil {
208
- return nil , err
212
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Inventory" )
209
213
}
210
214
}
211
215
if delta .DifferentAt ("Spec.Lifecycle" ) {
212
216
if err := rm .syncLifecycle (ctx , desired ); err != nil {
213
- return nil , err
217
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Lifecycle" )
214
218
}
215
219
}
216
220
if delta .DifferentAt ("Spec.Logging" ) {
217
221
if err := rm .syncLogging (ctx , desired ); err != nil {
218
- return nil , err
222
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Logging" )
219
223
}
220
224
}
221
225
if delta .DifferentAt ("Spec.Metrics" ) {
222
226
if err := rm .syncMetrics (ctx , desired , latest ); err != nil {
223
- return nil , err
227
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Metrics" )
224
228
}
225
229
}
226
230
if delta .DifferentAt ("Spec.Notification" ) {
227
231
if err := rm .syncNotification (ctx , desired ); err != nil {
228
- return nil , err
232
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Notification" )
229
233
}
230
234
}
231
235
if delta .DifferentAt ("Spec.OwnershipControls" ) {
232
236
if err := rm .syncOwnershipControls (ctx , desired ); err != nil {
233
- return nil , err
237
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "OwnershipControls" )
234
238
}
235
239
}
236
240
if delta .DifferentAt ("Spec.Policy" ) {
237
241
if err := rm .syncPolicy (ctx , desired ); err != nil {
238
- return nil , err
242
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Policy" )
239
243
}
240
244
}
241
245
if delta .DifferentAt ("Spec.PublicAccessBlock" ) {
242
246
if err := rm .syncPublicAccessBlock (ctx , desired ); err != nil {
243
- return nil , err
247
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "PublicAccessBlock" )
244
248
}
245
249
}
246
250
if delta .DifferentAt ("Spec.RequestPayment" ) {
247
251
if err := rm .syncRequestPayment (ctx , desired ); err != nil {
248
- return nil , err
252
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "RequestPayment" )
249
253
}
250
254
}
251
255
if delta .DifferentAt ("Spec.Tagging" ) {
252
256
if err := rm .syncTagging (ctx , desired ); err != nil {
253
- return nil , err
257
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Tagging" )
254
258
}
255
259
}
256
260
if delta .DifferentAt ("Spec.Website" ) {
257
261
if err := rm .syncWebsite (ctx , desired ); err != nil {
258
- return nil , err
262
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Website" )
259
263
}
260
264
}
261
265
@@ -265,17 +269,17 @@ func (rm *resourceManager) customUpdateBucket(
265
269
if delta .DifferentAt ("Spec.Replication" ) || delta .DifferentAt ("Spec.Versioning" ) {
266
270
if desired .ko .Spec .Replication == nil || desired .ko .Spec .Replication .Rules == nil {
267
271
if err := rm .syncReplication (ctx , desired ); err != nil {
268
- return nil , err
272
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
269
273
}
270
274
if err := rm .syncVersioning (ctx , desired ); err != nil {
271
- return nil , err
275
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Versioningc" )
272
276
}
273
277
} else {
274
278
if err := rm .syncVersioning (ctx , desired ); err != nil {
275
- return nil , err
279
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Versioningc" )
276
280
}
277
281
if err := rm .syncReplication (ctx , desired ); err != nil {
278
- return nil , err
282
+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
279
283
}
280
284
}
281
285
}
@@ -292,7 +296,14 @@ func (rm *resourceManager) addPutFieldsToSpec(
292
296
) (err error ) {
293
297
getAccelerateResponse , err := rm .sdkapi .GetBucketAccelerateConfigurationWithContext (ctx , rm .newGetBucketAcceleratePayload (r ))
294
298
if err != nil {
295
- return err
299
+ // This method is not supported in every region, ignore any errors if
300
+ // we attempt to describe this property in a region in which it's not
301
+ // supported.
302
+ if awsErr , ok := ackerr .AWSError (err ); ok && awsErr .Code () == "MethodNotAllowed" {
303
+ getAccelerateResponse = & svcsdk.GetBucketAccelerateConfigurationOutput {}
304
+ } else {
305
+ return err
306
+ }
296
307
}
297
308
ko .Spec .Accelerate = rm .setResourceAccelerate (r , getAccelerateResponse )
298
309
0 commit comments