@@ -17,6 +17,8 @@ import (
1717 "context"
1818 "strings"
1919
20+ "github.com/pkg/errors"
21+
2022 ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
2123 ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
2224 ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
@@ -50,6 +52,8 @@ const (
5052 ConfigurationActionUpdate
5153)
5254
55+ const ErrSyncingPutProperty = "Error syncing property '%s'"
56+
5357func (rm * resourceManager ) createPutFields (
5458 ctx context.Context ,
5559 r * resource ,
@@ -64,87 +68,87 @@ func (rm *resourceManager) createPutFields(
6468
6569 if r .ko .Spec .Accelerate != nil {
6670 if err := rm .syncAccelerate (ctx , r ); err != nil {
67- return err
71+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Accelerate" )
6872 }
6973 }
7074 if len (r .ko .Spec .Analytics ) != 0 {
7175 if err := rm .syncAnalytics (ctx , r , nil ); err != nil {
72- return err
76+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Analytics" )
7377 }
7478 }
7579 if r .ko .Spec .CORS != nil {
7680 if err := rm .syncCORS (ctx , r ); err != nil {
77- return err
81+ return errors . Wrapf ( err , ErrSyncingPutProperty , "CORS" )
7882 }
7983 }
8084 if r .ko .Spec .Encryption != nil {
8185 if err := rm .syncEncryption (ctx , r ); err != nil {
82- return err
86+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Encryption" )
8387 }
8488 }
8589 if len (r .ko .Spec .IntelligentTiering ) != 0 {
8690 if err := rm .syncIntelligentTiering (ctx , r , nil ); err != nil {
87- return err
91+ return errors . Wrapf ( err , ErrSyncingPutProperty , "IntelligentTiering" )
8892 }
8993 }
9094 if len (r .ko .Spec .Inventory ) != 0 {
9195 if err := rm .syncInventory (ctx , r , nil ); err != nil {
92- return err
96+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Inventory" )
9397 }
9498 }
9599 if r .ko .Spec .Lifecycle != nil {
96100 if err := rm .syncLifecycle (ctx , r ); err != nil {
97- return err
101+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Lifecycle" )
98102 }
99103 }
100104 if r .ko .Spec .Logging != nil {
101105 if err := rm .syncLogging (ctx , r ); err != nil {
102- return err
106+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Logging" )
103107 }
104108 }
105109 if len (r .ko .Spec .Metrics ) != 0 {
106110 if err := rm .syncMetrics (ctx , r , nil ); err != nil {
107- return err
111+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Metrics" )
108112 }
109113 }
110114 if r .ko .Spec .Notification != nil {
111115 if err := rm .syncNotification (ctx , r ); err != nil {
112- return err
116+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Notification" )
113117 }
114118 }
115119 if r .ko .Spec .OwnershipControls != nil {
116120 if err := rm .syncOwnershipControls (ctx , r ); err != nil {
117- return err
121+ return errors . Wrapf ( err , ErrSyncingPutProperty , "OwnershipControls" )
118122 }
119123 }
120124 if r .ko .Spec .Policy != nil {
121125 if err := rm .syncPolicy (ctx , r ); err != nil {
122- return err
126+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Policy" )
123127 }
124128 }
125129 if r .ko .Spec .PublicAccessBlock != nil {
126130 if err := rm .syncPublicAccessBlock (ctx , r ); err != nil {
127- return err
131+ return errors . Wrapf ( err , ErrSyncingPutProperty , "PublicAccessBlock" )
128132 }
129133 }
130134 if r .ko .Spec .Replication != nil {
131135 if err := rm .syncReplication (ctx , r ); err != nil {
132- return err
136+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
133137 }
134138 }
135139 if r .ko .Spec .RequestPayment != nil {
136140 if err := rm .syncRequestPayment (ctx , r ); err != nil {
137- return err
141+ return errors . Wrapf ( err , ErrSyncingPutProperty , "RequestPayment" )
138142 }
139143 }
140144 if r .ko .Spec .Tagging != nil {
141145 if err := rm .syncTagging (ctx , r ); err != nil {
142- return err
146+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Tagging" )
143147 }
144148 }
145149 if r .ko .Spec .Website != nil {
146150 if err := rm .syncWebsite (ctx , r ); err != nil {
147- return err
151+ return errors . Wrapf ( err , ErrSyncingPutProperty , "Website" )
148152 }
149153 }
150154 return nil
@@ -170,12 +174,12 @@ func (rm *resourceManager) customUpdateBucket(
170174
171175 if delta .DifferentAt ("Spec.Accelerate" ) {
172176 if err := rm .syncAccelerate (ctx , desired ); err != nil {
173- return nil , err
177+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Accelerate" )
174178 }
175179 }
176180 if delta .DifferentAt ("Spec.Analytics" ) {
177181 if err := rm .syncAnalytics (ctx , desired , latest ); err != nil {
178- return nil , err
182+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Analytics" )
179183 }
180184 }
181185 if delta .DifferentAt ("Spec.ACL" ) ||
@@ -185,77 +189,77 @@ func (rm *resourceManager) customUpdateBucket(
185189 delta .DifferentAt ("Spec.GrantWrite" ) ||
186190 delta .DifferentAt ("Spec.GrantWriteACP" ) {
187191 if err := rm .syncACL (ctx , desired ); err != nil {
188- return nil , err
192+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "ACLs or Grant Headers" )
189193 }
190194 }
191195 if delta .DifferentAt ("Spec.CORS" ) {
192196 if err := rm .syncCORS (ctx , desired ); err != nil {
193- return nil , err
197+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "CORS" )
194198 }
195199 }
196200 if delta .DifferentAt ("Spec.Encryption" ) {
197201 if err := rm .syncEncryption (ctx , desired ); err != nil {
198- return nil , err
202+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Encryption" )
199203 }
200204 }
201205 if delta .DifferentAt ("Spec.IntelligentTiering" ) {
202206 if err := rm .syncIntelligentTiering (ctx , desired , latest ); err != nil {
203- return nil , err
207+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "IntelligentTiering" )
204208 }
205209 }
206210 if delta .DifferentAt ("Spec.Inventory" ) {
207211 if err := rm .syncInventory (ctx , desired , latest ); err != nil {
208- return nil , err
212+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Inventory" )
209213 }
210214 }
211215 if delta .DifferentAt ("Spec.Lifecycle" ) {
212216 if err := rm .syncLifecycle (ctx , desired ); err != nil {
213- return nil , err
217+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Lifecycle" )
214218 }
215219 }
216220 if delta .DifferentAt ("Spec.Logging" ) {
217221 if err := rm .syncLogging (ctx , desired ); err != nil {
218- return nil , err
222+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Logging" )
219223 }
220224 }
221225 if delta .DifferentAt ("Spec.Metrics" ) {
222226 if err := rm .syncMetrics (ctx , desired , latest ); err != nil {
223- return nil , err
227+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Metrics" )
224228 }
225229 }
226230 if delta .DifferentAt ("Spec.Notification" ) {
227231 if err := rm .syncNotification (ctx , desired ); err != nil {
228- return nil , err
232+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Notification" )
229233 }
230234 }
231235 if delta .DifferentAt ("Spec.OwnershipControls" ) {
232236 if err := rm .syncOwnershipControls (ctx , desired ); err != nil {
233- return nil , err
237+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "OwnershipControls" )
234238 }
235239 }
236240 if delta .DifferentAt ("Spec.Policy" ) {
237241 if err := rm .syncPolicy (ctx , desired ); err != nil {
238- return nil , err
242+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Policy" )
239243 }
240244 }
241245 if delta .DifferentAt ("Spec.PublicAccessBlock" ) {
242246 if err := rm .syncPublicAccessBlock (ctx , desired ); err != nil {
243- return nil , err
247+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "PublicAccessBlock" )
244248 }
245249 }
246250 if delta .DifferentAt ("Spec.RequestPayment" ) {
247251 if err := rm .syncRequestPayment (ctx , desired ); err != nil {
248- return nil , err
252+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "RequestPayment" )
249253 }
250254 }
251255 if delta .DifferentAt ("Spec.Tagging" ) {
252256 if err := rm .syncTagging (ctx , desired ); err != nil {
253- return nil , err
257+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Tagging" )
254258 }
255259 }
256260 if delta .DifferentAt ("Spec.Website" ) {
257261 if err := rm .syncWebsite (ctx , desired ); err != nil {
258- return nil , err
262+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Website" )
259263 }
260264 }
261265
@@ -265,17 +269,17 @@ func (rm *resourceManager) customUpdateBucket(
265269 if delta .DifferentAt ("Spec.Replication" ) || delta .DifferentAt ("Spec.Versioning" ) {
266270 if desired .ko .Spec .Replication == nil || desired .ko .Spec .Replication .Rules == nil {
267271 if err := rm .syncReplication (ctx , desired ); err != nil {
268- return nil , err
272+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
269273 }
270274 if err := rm .syncVersioning (ctx , desired ); err != nil {
271- return nil , err
275+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Versioningc" )
272276 }
273277 } else {
274278 if err := rm .syncVersioning (ctx , desired ); err != nil {
275- return nil , err
279+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Versioningc" )
276280 }
277281 if err := rm .syncReplication (ctx , desired ); err != nil {
278- return nil , err
282+ return nil , errors . Wrapf ( err , ErrSyncingPutProperty , "Replication" )
279283 }
280284 }
281285 }
@@ -292,7 +296,14 @@ func (rm *resourceManager) addPutFieldsToSpec(
292296) (err error ) {
293297 getAccelerateResponse , err := rm .sdkapi .GetBucketAccelerateConfigurationWithContext (ctx , rm .newGetBucketAcceleratePayload (r ))
294298 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+ }
296307 }
297308 ko .Spec .Accelerate = rm .setResourceAccelerate (r , getAccelerateResponse )
298309
0 commit comments