Skip to content

Commit fb8640d

Browse files
authored
Use latest from sdk create/update for rm.onError() (#344)
Issue #, if available: aws-controllers-k8s/community#1336 Description of changes: * After the sdkCreate/sdkUpdate call, the resource manager was still using the latest from ReadOne call when invoking `rm.onError` method * Instead it should use the resource returned from sdkCreate and sdkUpdate call By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 23941cc commit fb8640d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

templates/pkg/resource/manager.go.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ func (rm *resourceManager) Create(
113113
}
114114
created, err := rm.sdkCreate(ctx, r)
115115
if err != nil {
116+
if created != nil {
117+
return rm.onError(created, err)
118+
}
116119
return rm.onError(r, err)
117120
}
118121
return rm.onSuccess(created)
@@ -140,6 +143,9 @@ func (rm *resourceManager) Update(
140143
}
141144
updated, err := rm.sdkUpdate(ctx, desired, latest, delta)
142145
if err != nil {
146+
if updated != nil {
147+
return rm.onError(updated, err)
148+
}
143149
return rm.onError(latest, err)
144150
}
145151
return rm.onSuccess(updated)

0 commit comments

Comments
 (0)